How to use the sanctuary-type-classes.toString function in sanctuary-type-classes

To help you get started, we’ve selected a few sanctuary-type-classes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github safareli / free / test / union.js View on Github external
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')
github fluture-js / fluture-express / test / index.js View on Github external
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);
}
github Avaq / permissionary / test / index.js View on Github external
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);
}
github safareli / free / src / union.js View on Github external
    this['@@values'].map(a => toString(a)).join(', ')
  })`