1 | var Test = require('tape/lib/test');
|
---|
2 | var is = require('object-is');
|
---|
3 | var equal = require('../');
|
---|
4 |
|
---|
5 | function equalReversed(t, a, b, isEqual, msg, isStrict, skipReversed) {
|
---|
6 | var actual = isStrict ? equal(a, b, { strict: true }) : equal(a, b);
|
---|
7 | var suffix = isEqual ? ' are equal' : ' are not equal';
|
---|
8 | t.equal(actual, !!isEqual, msg + suffix);
|
---|
9 | if (typeof skipReversed === 'boolean' ? !skipReversed : !is(a, b)) {
|
---|
10 | var actualReverse = isStrict ? equal(b, a, { strict: true }) : equal(b, a);
|
---|
11 | t.equal(actualReverse, !!isEqual, msg + suffix + ' (reversed)');
|
---|
12 | }
|
---|
13 | }
|
---|
14 | function deepEqualTest(t, a, b, msg, isEqual, isStrictEqual, skipReversed) {
|
---|
15 | equalReversed(t, a, b, isEqual, msg, false, skipReversed);
|
---|
16 | equalReversed(t, a, b, isStrictEqual, 'strict: ' + msg, true, skipReversed);
|
---|
17 | }
|
---|
18 |
|
---|
19 | Test.prototype.deepEqualTest = function (a, b, message, isEqual, isStrictEqual, skipReversed) {
|
---|
20 | return deepEqualTest(this, a, b, message, !!isEqual, !!isStrictEqual, skipReversed);
|
---|
21 | };
|
---|