diff --git a/lib/test.js b/lib/test.js index bf3cbd8a..6fb86242 100644 --- a/lib/test.js +++ b/lib/test.js @@ -417,12 +417,12 @@ Test.prototype.error = Test.prototype.iferror = error; -function equal(a, b, msg, extra) { +function strictEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } - this._assert(a == b, { - message: defined(msg, 'should be equal'), + this._assert(is(a, b), { + message: defined(msg, 'should be strictly equal'), operator: 'equal', actual: a, expected: b, @@ -432,103 +432,92 @@ function equal(a, b, msg, extra) { Test.prototype.equal = Test.prototype.equals = Test.prototype.isEqual -= equal; - -function strictEqual(a, b, msg, extra) { - if (arguments.length < 2) { - throw new TypeError('two arguments must be provided to compare'); - } - this._assert(is(a, b), { - message: defined(msg, 'should be strictly equal'), - operator: 'strictEqual', - actual: a, - expected: b, - extra: extra - }); -} -Test.prototype.strictEqual += Test.prototype.strictEqual = Test.prototype.strictEquals = Test.prototype.is = strictEqual; -function notEqual(a, b, msg, extra) { +function notStrictEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } - this._assert(a != b, { - message: defined(msg, 'should not be equal'), + this._assert(!is(a, b), { + message: defined(msg, 'should not be strictly equal'), operator: 'notEqual', actual: a, expected: b, extra: extra }); } + Test.prototype.notEqual = Test.prototype.notEquals = Test.prototype.isNotEqual = Test.prototype.doesNotEqual = Test.prototype.isInequal -= notEqual; += Test.prototype.notStrictEqual += Test.prototype.notStrictEquals += Test.prototype.isNot += Test.prototype.not += notStrictEqual; -function notStrictEqual(a, b, msg, extra) { +function looseEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } - this._assert(!is(a, b), { - message: defined(msg, 'should not be strictly equal'), - operator: 'notStrictEqual', + this._assert(a == b, { + message: defined(msg, 'should be loosely equal'), + operator: 'looseEqual', actual: a, expected: b, extra: extra }); } -Test.prototype.notStrictEqual -= Test.prototype.notStrictEquals -= Test.prototype.isNot -= Test.prototype.not -= notStrictEqual; -function tapeDeepEqual(a, b, msg, extra) { +Test.prototype.looseEqual += Test.prototype.looseEquals += looseEqual; + +function notLooseEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } - this._assert(deepEqual(a, b, { strict: true }), { - message: defined(msg, 'should be equivalent'), - operator: 'deepEqual', + this._assert(a != b, { + message: defined(msg, 'should not be loosely equal'), + operator: 'notLooseEqual', actual: a, expected: b, extra: extra }); } -Test.prototype.deepEqual -= Test.prototype.deepEquals -= Test.prototype.isEquivalent -= Test.prototype.same -= tapeDeepEqual; +Test.prototype.notLooseEqual += Test.prototype.notLooseEquals += notLooseEqual; -function deepLooseEqual(a, b, msg, extra) { +function tapeDeepEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } - this._assert(deepEqual(a, b), { - message: defined(msg, 'should be equivalent'), - operator: 'deepLooseEqual', + this._assert(deepEqual(a, b, { strict: true }), { + message: defined(msg, 'should be deeply equivalent'), + operator: 'deepEqual', actual: a, expected: b, extra: extra }); } -Test.prototype.deepLooseEqual -= Test.prototype.looseEqual -= Test.prototype.looseEquals -= deepLooseEqual; +Test.prototype.deepEqual += Test.prototype.deepEquals += Test.prototype.isEquivalent += Test.prototype.same += tapeDeepEqual; function notDeepEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } this._assert(!deepEqual(a, b, { strict: true }), { - message: defined(msg, 'should not be equivalent'), + message: defined(msg, 'should not be deeply equivalent'), operator: 'notDeepEqual', actual: a, expected: b, @@ -546,12 +535,28 @@ Test.prototype.notDeepEqual = Test.prototype.isInequivalent = notDeepEqual; +function deepLooseEqual(a, b, msg, extra) { + if (arguments.length < 2) { + throw new TypeError('two arguments must be provided to compare'); + } + this._assert(deepEqual(a, b), { + message: defined(msg, 'should be loosely deeply equivalent'), + operator: 'deepLooseEqual', + actual: a, + expected: b, + extra: extra + }); +} + +Test.prototype.deepLooseEqual += deepLooseEqual; + function notDeepLooseEqual(a, b, msg, extra) { if (arguments.length < 2) { throw new TypeError('two arguments must be provided to compare'); } this._assert(!deepEqual(a, b), { - message: defined(msg, 'should be equivalent'), + message: defined(msg, 'should not be loosely deeply equivalent'), operator: 'notDeepLooseEqual', actual: a, expected: b, @@ -559,8 +564,6 @@ function notDeepLooseEqual(a, b, msg, extra) { }); } Test.prototype.notDeepLooseEqual -= Test.prototype.notLooseEqual -= Test.prototype.notLooseEquals = notDeepLooseEqual; Test.prototype['throws'] = function (fn, expected, msg, extra) { diff --git a/readme.markdown b/readme.markdown index 756eeba1..3e66ca7d 100644 --- a/readme.markdown +++ b/readme.markdown @@ -27,8 +27,8 @@ test('timing test', function (t) { $ node example/timing.js TAP version 13 # timing test -ok 1 should be equal -not ok 2 should be equal +ok 1 should be strictly equal +not ok 2 should be strictly equal --- operator: equal expected: 100 @@ -217,27 +217,27 @@ Aliases: `t.ifError()`, `t.ifErr()`, `t.iferror()` ## t.equal(actual, expected, msg) -Assert that `actual == expected` with an optional description of the assertion `msg`. +Assert that `Object.is(actual, expected)` with an optional description of the assertion `msg`. -Aliases: `t.equals()`, `t.isEqual()` +Aliases: `t.equals()`, `t.isEqual()`, `t.strictEqual()`, `t.strictEquals()`, `t.is()` -## t.strictEqual(actual, expected, msg) +## t.notEqual(actual, expected, msg) -Assert that `Object.is(actual, expected)` with an optional description of the assertion `msg`. +Assert that `!Object.is(actual, expected)` with an optional description of the assertion `msg`. -Aliases: `t.is()`, `t.strictEqual()`, `t.strictEquals()` +Aliases: `t.notEquals()`, `t.isNotEqual()`, `t.doesNotEqual()`, `t.isInequal()`, `t.notStrictEqual()`, `t.notStrictEquals()`, `t.isNot()`, `t.not()` -## t.notEqual(actual, expected, msg) +## t.looseEqual(actual, expected, msg) -Assert that `actual != expected` with an optional description of the assertion `msg`. +Assert that `actual == expected` with an optional description of the assertion `msg`. -Aliases: `t.notEquals()`, `t.isNotEqual()`, `t.doesNotEqual()`, `t.isInequal()` +Aliases: `t.looseEquals()` -## t.notStrictEqual(actual, expected, msg) +## t.notLooseEqual(actual, expected, msg) -Assert that `!Object.is(actual, expected)` with an optional description of the assertion `msg`. +Assert that `actual != expected` with an optional description of the assertion `msg`. -Aliases: `t.notStrictEqual()`, `t.notStrictEquals()`, `t.isNot()`, `t.not()` +Aliases: `t.notLooseEquals()` ## t.deepEqual(actual, expected, msg) @@ -263,8 +263,6 @@ Assert that `actual` and `expected` have the same structure and nested values us [node's deepEqual() algorithm](https://github.com/substack/node-deep-equal) with loose comparisons (`==`) on leaf nodes and an optional description of the assertion `msg`. -Aliases: `t.looseEqual()`, `t.looseEquals()` - ## t.notDeepLooseEqual(actual, expected, msg) Assert that `actual` and `expected` do not have the same structure and nested values using @@ -347,14 +345,14 @@ Pass in test files to run as arguments: $ node tap.js test/x.js test/y.js TAP version 13 # (anonymous) -not ok 1 should be equal +not ok 1 should be strictly equal --- operator: equal expected: "boop" actual: "beep" ... # (anonymous) -ok 2 should be equal +ok 2 should be strictly equal ok 3 (unnamed assert) # wheee ok 4 (unnamed assert) @@ -387,10 +385,10 @@ The output for this runner is: ```sh $ node object.js test/x.js test/y.js {"type":"test","name":"(anonymous)","id":0} -{"id":0,"ok":false,"name":"should be equal","operator":"equal","actual":"beep","expected":"boop","error":{},"test":0,"type":"assert"} +{"id":0,"ok":false,"name":"should be strictly equal","operator":"equal","actual":"beep","expected":"boop","error":{},"test":0,"type":"assert"} {"type":"end","test":0} {"type":"test","name":"(anonymous)","id":1} -{"id":0,"ok":true,"name":"should be equal","operator":"equal","actual":2,"expected":2,"test":1,"type":"assert"} +{"id":0,"ok":true,"name":"should be strictly equal","operator":"equal","actual":2,"expected":2,"test":1,"type":"assert"} {"id":1,"ok":true,"name":"(unnamed assert)","operator":"ok","actual":true,"expected":true,"test":1,"type":"assert"} {"type":"end","test":1} {"type":"test","name":"wheee","id":2} diff --git a/test/array.js b/test/array.js index 0184fb26..d150b18e 100644 --- a/test/array.js +++ b/test/array.js @@ -14,11 +14,11 @@ tap.test('array test', function (tt) { tt.same(rows.toString('utf8'), [ 'TAP version 13', '# array', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'ok 5 should be deeply equivalent', '', '1..5', '# tests 5', diff --git a/test/circular-things.js b/test/circular-things.js index c2745cad..ae9462f0 100644 --- a/test/circular-things.js +++ b/test/circular-things.js @@ -15,7 +15,7 @@ tap.test('circular test', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# circular\n' - + 'not ok 1 should be equal\n' + + 'not ok 1 should be strictly equal\n' + ' ---\n' + ' operator: equal\n' + ' expected: |-\n' @@ -24,7 +24,7 @@ tap.test('circular test', function (assert) { + ' { circular: [Circular] }\n' + ' at: Test. ($TEST/circular-things.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should be equal\n' + + ' Error: should be strictly equal\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/circular-things.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' diff --git a/test/deep-equal-failure.js b/test/deep-equal-failure.js index fa32d651..a3f16b92 100644 --- a/test/deep-equal-failure.js +++ b/test/deep-equal-failure.js @@ -21,7 +21,7 @@ tap.test('deep equal failure', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# deep equal\n' - + 'not ok 1 should be equal\n' + + 'not ok 1 should be strictly equal\n' + ' ---\n' + ' operator: equal\n' + ' expected: |-\n' @@ -30,7 +30,7 @@ tap.test('deep equal failure', function (assert) { + ' { a: 1 }\n' + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should be equal\n' + + ' Error: should be strictly equal\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -55,7 +55,7 @@ tap.test('deep equal failure', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should be equal', + name: 'should be strictly equal', diag: { operator: 'equal', expected: '{ b: 2 }', @@ -82,7 +82,7 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# deep equal\n' - + 'not ok 1 should be equal\n' + + 'not ok 1 should be strictly equal\n' + ' ---\n' + ' operator: equal\n' + ' expected: |-\n' @@ -91,7 +91,7 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should be equal\n' + + ' Error: should be strictly equal\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -116,7 +116,7 @@ tap.test('deep equal failure, depth 6, with option', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should be equal', + name: 'should be strictly equal', diag: { operator: 'equal', expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }', @@ -143,7 +143,7 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# deep equal\n' - + 'not ok 1 should be equal\n' + + 'not ok 1 should be strictly equal\n' + ' ---\n' + ' operator: equal\n' + ' expected: |-\n' @@ -152,7 +152,7 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' + ' at: Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should be equal\n' + + ' Error: should be strictly equal\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -177,7 +177,7 @@ tap.test('deep equal failure, depth 6, without option', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should be equal', + name: 'should be strictly equal', diag: { operator: 'equal', expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', diff --git a/test/default-messages.js b/test/default-messages.js index 307ec89b..359c98a5 100644 --- a/test/default-messages.js +++ b/test/default-messages.js @@ -5,6 +5,8 @@ var path = require('path'); var spawn = require('child_process').spawn; var concat = require('concat-stream'); +var stripFullStack = require('./common').stripFullStack; + tap.test('default messages', function (t) { t.plan(1); @@ -12,22 +14,37 @@ tap.test('default messages', function (t) { ps.stdout.pipe(concat(function (rows) { - t.same(rows.toString('utf8'), [ + t.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# default messages', 'ok 1 should be truthy', 'ok 2 should be falsy', - 'ok 3 should be equal', - 'ok 4 should not be equal', - 'ok 5 should be equivalent', - 'ok 6 should be equivalent', - 'ok 7 should be equivalent', - '', - '1..7', - '# tests 7', - '# pass 7', + 'ok 3 should be strictly equal', + 'ok 4 should not be strictly equal', + 'ok 5 should be loosely equal', + 'ok 6 should not be loosely equal', + 'ok 7 should be strictly equal', + 'ok 8 should not be strictly equal', + 'ok 9 should be deeply equivalent', + 'not ok 10 should not be deeply equivalent', + ' ---', + ' operator: notDeepEqual', + ' expected: true', + ' actual: true', + ' at: Test. ($TEST/messages/defaults.js:$LINE:$COL)', + ' stack: |-', + ' Error: should not be deeply equivalent', + ' [... stack stripped ...]', + ' at Test. ($TEST/messages/defaults.js:$LINE:$COL)', + ' [... stack stripped ...]', + ' ...', + 'ok 11 should be loosely deeply equivalent', + 'ok 12 should not be loosely deeply equivalent', '', - '# ok' + '1..12', + '# tests 12', + '# pass 11', + '# fail 1' ].join('\n') + '\n\n'); })); }); diff --git a/test/double_end.js b/test/double_end.js index f7cd9e35..5dc6e2a0 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -41,7 +41,7 @@ test(function (t) { t.equal(stripped, [ 'TAP version 13', '# double end', - 'ok 1 should be equal', + 'ok 1 should be strictly equal', 'not ok 2 .end() already called', ' ---', ' operator: fail', diff --git a/test/edge-cases.js b/test/edge-cases.js index 00b0072c..93b6fceb 100644 --- a/test/edge-cases.js +++ b/test/edge-cases.js @@ -15,39 +15,69 @@ tap.test('edge cases', function (tt) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# zeroes\n' - + 'ok 1 0 equal to -0\n' - + 'ok 2 -0 equal to 0\n' - + 'not ok 3 0 notEqual to -0\n' + + 'not ok 1 0 equal to -0\n' + ' ---\n' - + ' operator: notEqual\n' + + ' operator: equal\n' + ' expected: |-\n' + ' -0\n' + ' actual: |-\n' + ' 0\n' + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: 0 notEqual to -0\n' + + ' Error: 0 equal to -0\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 4 -0 notEqual to 0\n' + + 'not ok 2 -0 equal to 0\n' + ' ---\n' - + ' operator: notEqual\n' + + ' operator: equal\n' + + ' expected: |-\n' + + ' 0\n' + + ' actual: |-\n' + + ' -0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: -0 equal to 0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 3 0 notEqual to -0\n' + + 'ok 4 -0 notEqual to 0\n' + + 'ok 5 0 looseEqual to -0\n' + + 'ok 6 -0 looseEqual to 0\n' + + 'not ok 7 0 notLooseEqual to -0\n' + + ' ---\n' + + ' operator: notLooseEqual\n' + + ' expected: |-\n' + + ' -0\n' + + ' actual: |-\n' + + ' 0\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: 0 notLooseEqual to -0\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 8 -0 notLooseEqual to 0\n' + + ' ---\n' + + ' operator: notLooseEqual\n' + ' expected: |-\n' + ' 0\n' + ' actual: |-\n' + ' -0\n' + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: -0 notEqual to 0\n' + + ' Error: -0 notLooseEqual to 0\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 5 0 strictEqual to -0\n' + + 'not ok 9 0 strictEqual to -0\n' + ' ---\n' - + ' operator: strictEqual\n' + + ' operator: equal\n' + ' expected: |-\n' + ' -0\n' + ' actual: |-\n' @@ -59,9 +89,9 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 6 -0 strictEqual to 0\n' + + 'not ok 10 -0 strictEqual to 0\n' + ' ---\n' - + ' operator: strictEqual\n' + + ' operator: equal\n' + ' expected: |-\n' + ' 0\n' + ' actual: |-\n' @@ -73,11 +103,11 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 7 0 notStrictEqual to -0\n' - + 'ok 8 -0 notStrictEqual to 0\n' - + 'ok 9 0 deepLooseEqual to -0\n' - + 'ok 10 -0 deepLooseEqual to 0\n' - + 'not ok 11 0 notDeepLooseEqual to -0\n' + + 'ok 11 0 notStrictEqual to -0\n' + + 'ok 12 -0 notStrictEqual to 0\n' + + 'ok 13 0 deepLooseEqual to -0\n' + + 'ok 14 -0 deepLooseEqual to 0\n' + + 'not ok 15 0 notDeepLooseEqual to -0\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: |-\n' @@ -91,7 +121,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 12 -0 notDeepLooseEqual to 0\n' + + 'not ok 16 -0 notDeepLooseEqual to 0\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: |-\n' @@ -105,7 +135,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 13 0 deepEqual to -0\n' + + 'not ok 17 0 deepEqual to -0\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: |-\n' @@ -119,7 +149,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 14 -0 deepEqual to 0\n' + + 'not ok 18 -0 deepEqual to 0\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: |-\n' @@ -133,26 +163,39 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 15 0 notDeepEqual to -0\n' - + 'ok 16 -0 notDeepEqual to 0\n' + + 'ok 19 0 notDeepEqual to -0\n' + + 'ok 20 -0 notDeepEqual to 0\n' + '# NaNs\n' - + 'not ok 17 NaN equal to NaN\n' + + 'ok 21 NaN equal to NaN\n' + + 'not ok 22 NaN notEqual to NaN\n' + ' ---\n' - + ' operator: equal\n' + + ' operator: notEqual\n' + ' expected: NaN\n' + ' actual: NaN\n' + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: NaN equal to NaN\n' + + ' Error: NaN notEqual to NaN\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 18 NaN notEqual to NaN\n' - + 'ok 19 NaN strictEqual to NaN\n' - + 'not ok 20 NaN notStrictEqual to NaN\n' + + 'not ok 23 NaN looseEqual to NaN\n' + ' ---\n' - + ' operator: notStrictEqual\n' + + ' operator: looseEqual\n' + + ' expected: NaN\n' + + ' actual: NaN\n' + + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: NaN looseEqual to NaN\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'ok 24 NaN notLooseEqual to NaN\n' + + 'ok 25 NaN strictEqual to NaN\n' + + 'not ok 26 NaN notStrictEqual to NaN\n' + + ' ---\n' + + ' operator: notEqual\n' + ' expected: NaN\n' + ' actual: NaN\n' + ' at: Test. ($TEST/edge-cases.js:$LINE:$COL)\n' @@ -162,7 +205,7 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 21 NaN deepLooseEqual to NaN\n' + + 'not ok 27 NaN deepLooseEqual to NaN\n' + ' ---\n' + ' operator: deepLooseEqual\n' + ' expected: NaN\n' @@ -174,9 +217,9 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 22 NaN notDeepLooseEqual to NaN\n' - + 'ok 23 NaN deepEqual to NaN\n' - + 'not ok 24 NaN notDeepEqual to NaN\n' + + 'ok 28 NaN notDeepLooseEqual to NaN\n' + + 'ok 29 NaN deepEqual to NaN\n' + + 'not ok 30 NaN notDeepEqual to NaN\n' + ' ---\n' + ' operator: notDeepEqual\n' + ' expected: NaN\n' @@ -188,10 +231,10 @@ tap.test('edge cases', function (tt) { + ' at Test. ($TEST/edge-cases.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + '\n1..24\n' - + '# tests 24\n' - + '# pass 12\n' - + '# fail 12\n' + + '\n1..30\n' + + '# tests 30\n' + + '# pass 15\n' + + '# fail 15\n' ); })); @@ -201,6 +244,11 @@ tap.test('edge cases', function (tt) { t.notEqual(0, -0, '0 notEqual to -0'); t.notEqual(-0, 0, '-0 notEqual to 0'); + t.looseEqual(0, -0, '0 looseEqual to -0'); + t.looseEqual(-0, 0, '-0 looseEqual to 0'); + t.notLooseEqual(0, -0, '0 notLooseEqual to -0'); + t.notLooseEqual(-0, 0, '-0 notLooseEqual to 0'); + t.strictEqual(0, -0, '0 strictEqual to -0'); t.strictEqual(-0, 0, '-0 strictEqual to 0'); t.notStrictEqual(0, -0, '0 notStrictEqual to -0'); @@ -223,6 +271,9 @@ tap.test('edge cases', function (tt) { t.equal(NaN, NaN, 'NaN equal to NaN'); t.notEqual(NaN, NaN, 'NaN notEqual to NaN'); + t.looseEqual(NaN, NaN, 'NaN looseEqual to NaN'); + t.notLooseEqual(NaN, NaN, 'NaN notLooseEqual to NaN'); + t.strictEqual(NaN, NaN, 'NaN strictEqual to NaN'); t.notStrictEqual(NaN, NaN, 'NaN notStrictEqual to NaN'); diff --git a/test/end-as-callback.js b/test/end-as-callback.js index 1781dcbe..84a751d7 100644 --- a/test/end-as-callback.js +++ b/test/end-as-callback.js @@ -13,10 +13,10 @@ tap.test("tape assert.end as callback", function (tt) { 'TAP version 13', '# do a task and write', 'ok 1 null', - 'ok 2 should be equal', + 'ok 2 should be strictly equal', '# do a task and write fail', 'ok 3 null', - 'ok 4 should be equal', + 'ok 4 should be strictly equal', 'not ok 5 Error: fail', getStackTrace(rows), // tap error stack '', diff --git a/test/exit.js b/test/exit.js index 093c46c1..326520f3 100644 --- a/test/exit.js +++ b/test/exit.js @@ -15,11 +15,11 @@ tap.test('exit ok', function (t) { 'TAP version 13', '# array', '# hi', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'ok 5 should be deeply equivalent', '', '1..5', '# tests 5', @@ -45,18 +45,18 @@ tap.test('exit fail', function (t) { t.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# array', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'not ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'not ok 5 should be deeply equivalent', ' ---', ' operator: deepEqual', ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]', ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]', ' at: Test. ($TEST/exit/fail.js:$LINE:$COL)', ' stack: |-', - ' Error: should be equivalent', + ' Error: should be deeply equivalent', ' [... stack stripped ...]', ' at $TEST/exit/fail.js:$LINE:$COL', ' at eval (eval at ($TEST/exit/fail.js:$LINE:$COL))', @@ -86,11 +86,11 @@ tap.test('too few exit', function (t) { t.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# array', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'ok 5 should be deeply equivalent', 'not ok 6 plan != count', ' ---', ' operator: fail', diff --git a/test/fail.js b/test/fail.js index 5b68fc87..6221b4c6 100644 --- a/test/fail.js +++ b/test/fail.js @@ -15,18 +15,18 @@ tap.test('array test', function (tt) { tt.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# array', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'not ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'not ok 5 should be deeply equivalent', ' ---', ' operator: deepEqual', ' expected: [ [ 1, 2, [ 3, 4444 ] ], [ 5, 6 ] ]', ' actual: [ [ 1, 2, [ 3, 4 ] ], [ 5, 6 ] ]', ' at: Test. ($TEST/fail.js:$LINE:$COL)', ' stack: |-', - ' Error: should be equivalent', + ' Error: should be deeply equivalent', ' [... stack stripped ...]', ' at $TEST/fail.js:$LINE:$COL', ' at eval (eval at ($TEST/fail.js:$LINE:$COL))', diff --git a/test/messages/defaults.js b/test/messages/defaults.js index ee3bfc1e..e9672147 100644 --- a/test/messages/defaults.js +++ b/test/messages/defaults.js @@ -3,12 +3,23 @@ var test = require('../../'); test('default messages', function (t) { - t.plan(7); + t.plan(12); + t.ok(true); t.notOk(false); + t.equal(true, true); t.notEqual(true, false); + + t.looseEqual(true, true); + t.notLooseEqual(true, false); + + t.strictEqual(true, true); + t.notStrictEqual(true, false); + t.deepEqual(true, true); + t.notDeepEqual(true, true); + t.deepLooseEqual(true, true); t.notDeepLooseEqual(true, false); }); diff --git a/test/nested.js b/test/nested.js index 7eefe90b..98c9398c 100644 --- a/test/nested.js +++ b/test/nested.js @@ -13,11 +13,11 @@ tap.test('array test', function (tt) { tt.same(rows.toString('utf8'), [ 'TAP version 13', '# nested array test', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', - 'ok 5 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', + 'ok 5 should be deeply equivalent', '# inside test', 'ok 6 should be truthy', 'ok 7 should be truthy', diff --git a/test/not-deep-equal-failure.js b/test/not-deep-equal-failure.js index 08b0df5f..849135ab 100644 --- a/test/not-deep-equal-failure.js +++ b/test/not-deep-equal-failure.js @@ -21,7 +21,7 @@ tap.test('deep equal failure', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' + + 'not ok 1 should not be deeply equivalent\n' + ' ---\n' + ' operator: notDeepEqual\n' + ' expected: |-\n' @@ -30,7 +30,7 @@ tap.test('deep equal failure', function (assert) { + ' { b: 2 }\n' + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should not be equivalent\n' + + ' Error: should not be deeply equivalent\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -55,7 +55,7 @@ tap.test('deep equal failure', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should not be equivalent', + name: 'should not be deeply equivalent', diag: { operator: 'notDeepEqual', expected: '{ b: 2 }', @@ -82,7 +82,7 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' + + 'not ok 1 should not be deeply equivalent\n' + ' ---\n' + ' operator: notDeepEqual\n' + ' expected: |-\n' @@ -91,7 +91,7 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n' + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should not be equivalent\n' + + ' Error: should not be deeply equivalent\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -116,7 +116,7 @@ tap.test('not deep equal failure, depth 6, with option', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should not be equivalent', + name: 'should not be deeply equivalent', diag: { operator: 'notDeepEqual', expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }', @@ -143,7 +143,7 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# not deep equal\n' - + 'not ok 1 should not be equivalent\n' + + 'not ok 1 should not be deeply equivalent\n' + ' ---\n' + ' operator: notDeepEqual\n' + ' expected: |-\n' @@ -152,7 +152,7 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n' + ' at: Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should not be equivalent\n' + + ' Error: should not be deeply equivalent\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -177,7 +177,7 @@ tap.test('not deep equal failure, depth 6, without option', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should not be equivalent', + name: 'should not be deeply equivalent', diag: { operator: 'notDeepEqual', expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }', diff --git a/test/not-equal-failure.js b/test/not-equal-failure.js index f3c528aa..a02abd7d 100644 --- a/test/not-equal-failure.js +++ b/test/not-equal-failure.js @@ -21,14 +21,14 @@ tap.test('not equal failure', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# not equal\n' - + 'not ok 1 should not be equal\n' + + 'not ok 1 should not be strictly equal\n' + ' ---\n' + ' operator: notEqual\n' + ' expected: 2\n' + ' actual: 2\n' + ' at: Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should not be equal\n' + + ' Error: should not be strictly equal\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/not-equal-failure.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' @@ -53,7 +53,7 @@ tap.test('not equal failure', function (assert) { assert.deepEqual(data, { ok: false, id: 1, - name: 'should not be equal', + name: 'should not be strictly equal', diag: { operator: 'notEqual', expected: '2', diff --git a/test/numerics.js b/test/numerics.js index 7c3f7554..a7a40204 100644 --- a/test/numerics.js +++ b/test/numerics.js @@ -15,35 +15,61 @@ tap.test('numerics', function (tt) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# numeric strings\n' - + 'ok 1 number equal to string\n' - + 'ok 2 string equal to number\n' - + 'not ok 3 number notEqual to string\n' + + 'not ok 1 number equal to string\n' + ' ---\n' - + ' operator: notEqual\n' + + ' operator: equal\n' + ' expected: \'3\'\n' + ' actual: 3\n' + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: number notEqual to string\n' + + ' Error: number equal to string\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 4 string notEqual to number\n' + + 'not ok 2 string equal to number\n' + ' ---\n' - + ' operator: notEqual\n' + + ' operator: equal\n' + ' expected: 3\n' + ' actual: \'3\'\n' + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: string notEqual to number\n' + + ' Error: string equal to number\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 5 number strictEqual to string\n' + + 'ok 3 number notEqual to string\n' + + 'ok 4 string notEqual to number\n' + + 'ok 5 number looseEqual to string\n' + + 'ok 6 string looseEqual to number\n' + + 'not ok 7 number notLooseEqual to string\n' + ' ---\n' - + ' operator: strictEqual\n' + + ' operator: notLooseEqual\n' + + ' expected: \'3\'\n' + + ' actual: 3\n' + + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: number notLooseEqual to string\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 8 string notLooseEqual to number\n' + + ' ---\n' + + ' operator: notLooseEqual\n' + + ' expected: 3\n' + + ' actual: \'3\'\n' + + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' + + ' stack: |-\n' + + ' Error: string notLooseEqual to number\n' + + ' [... stack stripped ...]\n' + + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + + ' [... stack stripped ...]\n' + + ' ...\n' + + 'not ok 9 number strictEqual to string\n' + + ' ---\n' + + ' operator: equal\n' + ' expected: \'3\'\n' + ' actual: 3\n' + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' @@ -53,9 +79,9 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 6 string strictEqual to number\n' + + 'not ok 10 string strictEqual to number\n' + ' ---\n' - + ' operator: strictEqual\n' + + ' operator: equal\n' + ' expected: 3\n' + ' actual: \'3\'\n' + ' at: Test. ($TEST/numerics.js:$LINE:$COL)\n' @@ -65,11 +91,11 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 7 number notStrictEqual to string\n' - + 'ok 8 string notStrictEqual to number\n' - + 'ok 9 number deepLooseEqual to string\n' - + 'ok 10 string deepLooseEqual to number\n' - + 'not ok 11 number notDeepLooseEqual to string\n' + + 'ok 11 number notStrictEqual to string\n' + + 'ok 12 string notStrictEqual to number\n' + + 'ok 13 number deepLooseEqual to string\n' + + 'ok 14 string deepLooseEqual to number\n' + + 'not ok 15 number notDeepLooseEqual to string\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: \'3\'\n' @@ -81,7 +107,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 12 string notDeepLooseEqual to number\n' + + 'not ok 16 string notDeepLooseEqual to number\n' + ' ---\n' + ' operator: notDeepLooseEqual\n' + ' expected: 3\n' @@ -93,7 +119,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 13 number deepEqual to string\n' + + 'not ok 17 number deepEqual to string\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: \'3\'\n' @@ -105,7 +131,7 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'not ok 14 string deepEqual to number\n' + + 'not ok 18 string deepEqual to number\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: 3\n' @@ -117,12 +143,12 @@ tap.test('numerics', function (tt) { + ' at Test. ($TEST/numerics.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n' + ' ...\n' - + 'ok 15 number notDeepEqual to string\n' - + 'ok 16 string notDeepEqual to number\n' - + '\n1..16\n' - + '# tests 16\n' - + '# pass 8\n' - + '# fail 8\n' + + 'ok 19 number notDeepEqual to string\n' + + 'ok 20 string notDeepEqual to number\n' + + '\n1..20\n' + + '# tests 20\n' + + '# pass 10\n' + + '# fail 10\n' ); })); @@ -132,6 +158,11 @@ tap.test('numerics', function (tt) { t.notEqual(3, '3', 'number notEqual to string'); t.notEqual('3', 3, 'string notEqual to number'); + t.looseEqual(3, '3', 'number looseEqual to string'); + t.looseEqual('3', 3, 'string looseEqual to number'); + t.notLooseEqual(3, '3', 'number notLooseEqual to string'); + t.notLooseEqual('3', 3, 'string notLooseEqual to number'); + t.strictEqual(3, '3', 'number strictEqual to string'); t.strictEqual('3', 3, 'string strictEqual to number'); t.notStrictEqual(3, '3', 'number notStrictEqual to string'); diff --git a/test/todo_single.js b/test/todo_single.js index 01591e27..eeb7d265 100644 --- a/test/todo_single.js +++ b/test/todo_single.js @@ -16,7 +16,7 @@ tap.test('tape todo test', function (assert) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# TODO failure\n' - + 'not ok 1 should be equal # TODO\n' + + 'not ok 1 should be strictly equal # TODO\n' + ' ---\n' + ' operator: equal\n' + ' expected: false\n' diff --git a/test/too_many.js b/test/too_many.js index f9cc7c4f..dc47b7b2 100644 --- a/test/too_many.js +++ b/test/too_many.js @@ -15,10 +15,10 @@ tap.test('array test', function (tt) { tt.same(stripFullStack(rows.toString('utf8')), [ 'TAP version 13', '# array', - 'ok 1 should be equivalent', - 'ok 2 should be equivalent', - 'ok 3 should be equivalent', - 'ok 4 should be equivalent', + 'ok 1 should be deeply equivalent', + 'ok 2 should be deeply equivalent', + 'ok 3 should be deeply equivalent', + 'ok 4 should be deeply equivalent', 'not ok 5 plan != count', ' ---', ' operator: fail', @@ -34,7 +34,7 @@ tap.test('array test', function (tt) { ' at Test. ($TEST/too_many.js:$LINE:$COL)', ' [... stack stripped ...]', ' ...', - 'ok 6 should be equivalent', + 'ok 6 should be deeply equivalent', '', '1..6', '# tests 6', diff --git a/test/undef.js b/test/undef.js index 2e210545..3f935be0 100644 --- a/test/undef.js +++ b/test/undef.js @@ -15,7 +15,7 @@ tap.test('array test', function (tt) { stripFullStack(body.toString('utf8')), 'TAP version 13\n' + '# undef\n' - + 'not ok 1 should be equivalent\n' + + 'not ok 1 should be deeply equivalent\n' + ' ---\n' + ' operator: deepEqual\n' + ' expected: |-\n' @@ -24,7 +24,7 @@ tap.test('array test', function (tt) { + ' {}\n' + ' at: Test. ($TEST/undef.js:$LINE:$COL)\n' + ' stack: |-\n' - + ' Error: should be equivalent\n' + + ' Error: should be deeply equivalent\n' + ' [... stack stripped ...]\n' + ' at Test. ($TEST/undef.js:$LINE:$COL)\n' + ' [... stack stripped ...]\n'