Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('misc', (t) => {
const list = List.Cons(a, List.Nil)
t.throws(() => { list.cata({ Cons: (a, b) => a }) }, 'throws if all cases are not handled')
t.throws(() => { List.Cons(1) }, 'when creating a tagged type with to many arguments throws error')
t.throws(() => { List.Cons(1, 1, 1) }, 'when creating a tagged type with to many arguments throws error')
t.same(list.toString(), `List.Cons(${toString(a)}, List.Nil())`, 'toString on value should work')
t.same(List.toString(), 'List', 'toString on type should work')
t.same(List.Cons.toString(), 'List.Cons', 'toString on variant constructor should work')
t.same(List.Nil.toString(), 'List.Nil()', 'toString on unit variant should work')
t.same(list.x, a, 'when checking head value should return correct value')
t.same(list.xs, List.Nil, 'when checking value value should return correct value')
t.same(list.cata({
Cons: (x, xs) => [x, xs],
Nil: () => [],
}), [list.x, list.xs], 'cata should work on Cons')
t.same(List.Nil.cata({
Cons: () => false,
Nil: () => true,
}), true, 'cata should work on Nil')
t.same(List.is(list), true, '`is` on type works')
t.same(List.is({}), false, '`is` on type works')
t.same(List.Cons.is(list), true, '`is` on variant works')
function eq(actual, expected) {
assert.strictEqual (arguments.length, eq.length);
assert.strictEqual (Z.toString (actual), Z.toString (expected));
assert.strictEqual (Z.equals (actual, expected), true);
}
function eq(actual, expected) {
assert.strictEqual (arguments.length, eq.length);
assert.strictEqual (Z.toString (actual), Z.toString (expected));
assert.strictEqual (Z.equals (actual, expected), true);
}
this['@@values'].map(a => toString(a)).join(', ')
})`