Skip to content

Commit

Permalink
[Tests] port tests from main; only diff should be true/falses
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 7, 2023
1 parent 270d34b commit e02cadb
Show file tree
Hide file tree
Showing 6 changed files with 1,074 additions and 113 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
"overrides": [
{
"files": ["example/**", "test/**"],
"globals": {
"Uint8Array": false,
"Int8Array": false,
},
"rules": {
"id-length": 0,
"max-lines-per-function": 0,
"max-params": 0,
"no-console": 0,
},
Expand Down
65 changes: 0 additions & 65 deletions .github/workflows/node-assert.yml

This file was deleted.

3 changes: 3 additions & 0 deletions assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('assert');
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
"aud": "^2.0.3",
"auto-changelog": "^2.4.0",
"eslint": "=8.8.0",
"has-typed-arrays": "^1.0.1",
"in-publish": "^2.0.1",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object.getownpropertydescriptors": "^2.1.7",
"safe-publish-latest": "^2.0.0",
"semver": "^6.3.1",
"tape": "^5.7.2"
},
"repository": {
Expand Down Expand Up @@ -91,6 +94,9 @@
"backfillLimit": false,
"hideCredit": true
},
"browser": {
"assert.js": false
},
"publishConfig": {
"ignore": [
".github/workflows"
Expand Down
27 changes: 24 additions & 3 deletions test/_tape.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
'use strict';

var Test = require('tape/lib/test');
var is = require('object-is');
var equal = require('../');

var deepEqual = require('../');
var assert = require('../assert');

var equal = process.env.ASSERT ? function assertDeepEqual(a, b, options) {
try {
if (options && options.strict) {
assert.deepStrictEqual(a, b);
} else {
assert.deepEqual(a, b);
}
} catch (e) {
return false;
}
return true;
} : deepEqual;

function equalReversed(t, a, b, isEqual, msg, isStrict, skipReversed) {
var actual = isStrict ? equal(a, b, { strict: true }) : equal(a, b);
var actual = isStrict
? equal(a, b, { strict: true })
: equal(a, b);
var suffix = isEqual ? ' are equal' : ' are not equal';
t.equal(actual, !!isEqual, msg + suffix);
if (typeof skipReversed === 'boolean' ? !skipReversed : !is(a, b)) {
var actualReverse = isStrict ? equal(b, a, { strict: true }) : equal(b, a);
var actualReverse = isStrict
? equal(b, a, { strict: true })
: equal(b, a);
t.equal(actualReverse, !!isEqual, msg + suffix + ' (reversed)');
}
}
Expand Down
Loading

0 comments on commit e02cadb

Please sign in to comment.