diff --git a/test/difference.js b/test/difference.js index c891002a7..d7dc34ea4 100644 --- a/test/difference.js +++ b/test/difference.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('difference', function() { @@ -18,11 +19,6 @@ describe('difference', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.difference([0], [-0]).length, 1); eq(R.difference([-0], [0]).length, 1); eq(R.difference([NaN], [NaN]).length, 0); diff --git a/test/dropRepeats.js b/test/dropRepeats.js index 2c40ddcac..79fb82f86 100644 --- a/test/dropRepeats.js +++ b/test/dropRepeats.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('dropRepeats', function() { @@ -21,11 +22,6 @@ describe('dropRepeats', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.dropRepeats([0, -0]).length, 2); eq(R.dropRepeats([-0, 0]).length, 2); eq(R.dropRepeats([NaN, NaN]).length, 1); diff --git a/test/eqBy.js b/test/eqBy.js index c584851c2..037bf5e09 100644 --- a/test/eqBy.js +++ b/test/eqBy.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('eqBy', function() { @@ -13,11 +14,6 @@ describe('eqBy', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.eqBy(R.identity, 0, -0), false); eq(R.eqBy(R.identity, -0, 0), false); eq(R.eqBy(R.identity, NaN, NaN), true); diff --git a/test/eqProps.js b/test/eqProps.js index c43493014..bdc6ef36d 100644 --- a/test/eqProps.js +++ b/test/eqProps.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('eqProps', function() { @@ -9,11 +10,6 @@ describe('eqProps', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.eqProps('value', {value: 0}, {value: -0}), false); eq(R.eqProps('value', {value: -0}, {value: 0}), false); eq(R.eqProps('value', {value: NaN}, {value: NaN}), true); diff --git a/test/filter.js b/test/filter.js index e3eb6b7d5..503f3eaa0 100644 --- a/test/filter.js +++ b/test/filter.js @@ -1,6 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); -var Maybe = require('./shared/Maybe.js'); +var {Just} = require('./shared/Maybe.js'); describe('filter', function() { @@ -33,7 +33,7 @@ describe('filter', function() { }); it('correctly uses fantasy-land implementations', function() { - var m1 = Maybe.Just(-1); + var m1 = Just(-1); var m2 = R.filter(function(x) { return x > 0; } , m1); eq(m2.isNothing, true); diff --git a/test/includes.js b/test/includes.js index 772001493..ef802fad7 100644 --- a/test/includes.js +++ b/test/includes.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('includes', function() { @@ -16,11 +17,6 @@ describe('includes', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.includes(0, [-0]), false); eq(R.includes(-0, [0]), false); eq(R.includes(NaN, [NaN]), true); diff --git a/test/indexOf.js b/test/indexOf.js index 47d32ac67..ef4d2e5c3 100644 --- a/test/indexOf.js +++ b/test/indexOf.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('indexOf', function() { @@ -46,11 +47,6 @@ describe('indexOf', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.indexOf(0, [-0]), -1); eq(R.indexOf(-0, [0]), -1); eq(R.indexOf(NaN, [NaN]), 0); diff --git a/test/intersection.js b/test/intersection.js index 858aa8f49..3806374a3 100644 --- a/test/intersection.js +++ b/test/intersection.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('intersection', function() { @@ -24,11 +25,6 @@ describe('intersection', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.intersection([0], [-0]).length, 0); eq(R.intersection([-0], [0]).length, 0); eq(R.intersection([NaN], [NaN]).length, 1); diff --git a/test/lastIndexOf.js b/test/lastIndexOf.js index 2f118e38f..2e9b98b64 100644 --- a/test/lastIndexOf.js +++ b/test/lastIndexOf.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('lastIndexOf', function() { @@ -37,11 +38,6 @@ describe('lastIndexOf', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.lastIndexOf(0, [-0]), -1); eq(R.lastIndexOf(-0, [0]), -1); eq(R.lastIndexOf(NaN, [NaN]), 0); diff --git a/test/lift.js b/test/lift.js index 38ad6e9e1..d39729d85 100644 --- a/test/lift.js +++ b/test/lift.js @@ -1,7 +1,7 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); -var Maybe = require('./shared/Maybe.js'); +var {Just} = require('./shared/Maybe.js'); var not = function(x) { return !x; }; var add3 = R.curry(function add3(a, b, c) { @@ -40,7 +40,7 @@ describe('lift', function() { it('works with other functors such as "Maybe"', function() { var addM = R.lift(R.add); - eq(addM(Maybe.Just(3), Maybe.Just(5)), Maybe.Just(8)); + eq(addM(Just(3), Just(5)), Just(8)); }); }); diff --git a/test/liftN.js b/test/liftN.js index 8d9ce06de..34fa3cd4a 100644 --- a/test/liftN.js +++ b/test/liftN.js @@ -1,7 +1,7 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); -var Maybe = require('./shared/Maybe.js'); +var {Just} = require('./shared/Maybe.js'); var addN = function() { @@ -34,7 +34,7 @@ describe('liftN', function() { it('works with other functors such as "Maybe"', function() { var addM = R.liftN(2, R.add); - eq(addM(Maybe.Just(3), Maybe.Just(5)), Maybe.Just(8)); + eq(addM(Just(3), Just(5)), Just(8)); }); it('interprets [a] as a functor', function() { diff --git a/test/pathEq.js b/test/pathEq.js index bf65e4bbb..4c648c4a1 100644 --- a/test/pathEq.js +++ b/test/pathEq.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('pathEq', function() { @@ -34,11 +35,6 @@ describe('pathEq', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.pathEq(0, ['value'], {value: -0}), false); eq(R.pathEq(-0, ['value'], {value: 0}), false); eq(R.pathEq(NaN, ['value'], {value: NaN}), true); diff --git a/test/propEq.js b/test/propEq.js index 15d695632..4c47374b9 100644 --- a/test/propEq.js +++ b/test/propEq.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('propEq', function() { @@ -22,11 +23,6 @@ describe('propEq', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.propEq(0, 'value', {value: -0}), false); eq(R.propEq(-0, 'value', {value: 0}), false); eq(R.propEq(NaN, 'value', {value: NaN}), true); diff --git a/test/reject.js b/test/reject.js index 256589a90..7e52c2bcf 100644 --- a/test/reject.js +++ b/test/reject.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just, Nothing} = require('./shared/Maybe.js'); describe('reject', function() { @@ -26,21 +27,10 @@ describe('reject', function() { }); it('dispatches to `filter` method', function() { - function Nothing() {} - Nothing.value = new Nothing(); - Nothing.prototype.filter = function() { - return this; - }; - - function Just(x) { this.value = x; } - Just.prototype.filter = function(pred) { - return pred(this.value) ? this : Nothing.value; - }; - var m = new Just(42); eq(R.filter(R.T, m), m); - eq(R.filter(R.F, m), Nothing.value); - eq(R.reject(R.T, m), Nothing.value); + eq(R.filter(R.F, m), Nothing); + eq(R.reject(R.T, m), Nothing); eq(R.reject(R.F, m), m); }); diff --git a/test/symmetricDifference.js b/test/symmetricDifference.js index 1a4f11bfb..46a5c2cf5 100644 --- a/test/symmetricDifference.js +++ b/test/symmetricDifference.js @@ -1,6 +1,7 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); var fc = require('fast-check'); +var {Just} = require('./shared/Maybe.js'); describe('symmetricDifference', function() { @@ -20,11 +21,6 @@ describe('symmetricDifference', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.symmetricDifference([0], [-0]).length, 2); eq(R.symmetricDifference([-0], [0]).length, 2); eq(R.symmetricDifference([NaN], [NaN]).length, 0); diff --git a/test/toString.js b/test/toString.js index eaa723744..be5a07910 100644 --- a/test/toString.js +++ b/test/toString.js @@ -1,6 +1,7 @@ var assert = require('assert'); var R = require('../source/index.js'); +var {Just} = require('./shared/Maybe.js'); describe('toString', function() { @@ -148,15 +149,6 @@ describe('toString', function() { }; assert.strictEqual(R.toString(new Point(1, 2)), 'new Point(1, 2)'); - function Just(x) { - if (!(this instanceof Just)) { - return new Just(x); - } - this.value = x; - } - Just.prototype.toString = function() { - return 'Just(' + R.toString(this.value) + ')'; - }; assert.strictEqual(R.toString(Just(42)), 'Just(42)'); assert.strictEqual(R.toString(Just([1, 2, 3])), 'Just([1, 2, 3])'); assert.strictEqual(R.toString(Just(Just(Just('')))), 'Just(Just(Just("")))'); diff --git a/test/union.js b/test/union.js index 8415f6f20..bcda204c4 100644 --- a/test/union.js +++ b/test/union.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('union', function() { @@ -10,11 +11,6 @@ describe('union', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.union([0], [-0]).length, 2); eq(R.union([-0], [0]).length, 2); eq(R.union([NaN], [NaN]).length, 1); diff --git a/test/uniq.js b/test/uniq.js index d421a5281..1e2d07529 100644 --- a/test/uniq.js +++ b/test/uniq.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('uniq', function() { @@ -17,11 +18,6 @@ describe('uniq', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.uniq([-0, -0]).length, 1); eq(R.uniq([0, -0]).length, 2); eq(R.uniq([NaN, NaN]).length, 1); diff --git a/test/uniqBy.js b/test/uniqBy.js index cd009a16d..3f55b2552 100644 --- a/test/uniqBy.js +++ b/test/uniqBy.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('uniqBy', function() { @@ -17,12 +18,6 @@ describe('uniqBy', function() { }); it('has R.equals semantics', function() { - function Just(x) { - this.value = x; - } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; eq(R.uniqBy(R.identity, [-0, 0]).length, 2); eq(R.uniqBy(R.identity, [NaN, NaN]).length, 1); eq(R.uniqBy(R.identity, [new Just([1, 2, 3]), new Just([1, 2, 3])]).length, 1); diff --git a/test/unnest.js b/test/unnest.js index 936f75a80..40976f7c4 100644 --- a/test/unnest.js +++ b/test/unnest.js @@ -2,7 +2,7 @@ var assert = require('assert'); var R = require('../source/index.js'); var eq = require('./shared/eq.js'); -var Maybe = require('./shared/Maybe.js'); +var {Just, Nothing} = require('./shared/Maybe.js'); describe('unnest', function() { @@ -31,9 +31,6 @@ describe('unnest', function() { }); it('is equivalent to R.chain(R.identity)', function() { - var Nothing = Maybe.Nothing; - var Just = Maybe.Just; - eq(R.unnest(Nothing), Nothing); eq(R.unnest(Just(Nothing)), Nothing); eq(R.unnest(Just(Just(Nothing))), Just(Nothing)); diff --git a/test/without.js b/test/without.js index 7b0022f31..79c3041ee 100644 --- a/test/without.js +++ b/test/without.js @@ -1,5 +1,6 @@ var R = require('../source/index.js'); var eq = require('./shared/eq.js'); +var {Just} = require('./shared/Maybe.js'); describe('without', function() { @@ -13,11 +14,6 @@ describe('without', function() { }); it('has R.equals semantics', function() { - function Just(x) { this.value = x; } - Just.prototype.equals = function(x) { - return x instanceof Just && R.equals(x.value, this.value); - }; - eq(R.without([0], [-0]).length, 1); eq(R.without([-0], [0]).length, 1); eq(R.without([NaN], [NaN]).length, 0);