You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
974 B

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