Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function notEqual(a, b, msg, extra) {
message : defined(msg, 'should not be equal'),
operator : 'notEqual',
actual : a,
notExpected : b,
expected : b,
extra : extra
});
}
Expand Down Expand Up @@ -451,7 +451,7 @@ function notDeepEqual(a, b, msg, extra) {
message : defined(msg, 'should not be equivalent'),
operator : 'notDeepEqual',
actual : a,
notExpected : b,
expected : b,
extra : extra
});
}
Expand Down
191 changes: 191 additions & 0 deletions test/not-deep-equal-failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var tapParser = require('tap-parser');
var common = require('./common');

var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;

tap.test('deep equal failure', function (assert) {
var test = tape.createHarness({ exit : false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);

stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.equal(
stripFullStack(body.toString('utf8')),
'TAP version 13\n'
+ '# not deep equal\n'
+ 'not ok 1 should not be equivalent\n'
+ ' ---\n'
+ ' operator: notDeepEqual\n'
+ ' expected: |-\n'
+ ' { b: 2 }\n'
+ ' actual: |-\n'
+ ' { b: 2 }\n'
+ ' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: should not be equivalent\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);

assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ b: 2 }',
actual: '{ b: 2 }'
});
}));

parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ b: 2 }',
actual: '{ b: 2 }'
}
});
});

test("not deep equal", function (t) {
t.plan(1);
t.notDeepEqual({b: 2}, {b: 2});
});
})

tap.test('not deep equal failure, depth 6, with option', function (assert) {
var test = tape.createHarness({ exit : false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);

stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.equal(
stripFullStack(body.toString('utf8')),
'TAP version 13\n'
+ '# not deep equal\n'
+ 'not ok 1 should not be equivalent\n'
+ ' ---\n'
+ ' operator: notDeepEqual\n'
+ ' expected: |-\n'
+ ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
+ ' actual: |-\n'
+ ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
+ ' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: should not be equivalent\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);

assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
});
}));

parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
}
});
});

test("not deep equal", {objectPrintDepth: 6}, function (t) {
t.plan(1);
t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } });
});
})

tap.test('not deep equal failure, depth 6, without option', function (assert) {
var test = tape.createHarness({ exit : false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);

stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.equal(
stripFullStack(body.toString('utf8')),
'TAP version 13\n'
+ '# not deep equal\n'
+ 'not ok 1 should not be equivalent\n'
+ ' ---\n'
+ ' operator: notDeepEqual\n'
+ ' expected: |-\n'
+ ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n'
+ ' actual: |-\n'
+ ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n'
+ ' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: should not be equivalent\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);

assert.deepEqual(getDiag(body), {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
});
}));

parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be equivalent',
diag: {
operator: 'notDeepEqual',
expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
}
});
});

test("not deep equal", function (t) {
t.plan(1);
t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } });
});
})
67 changes: 67 additions & 0 deletions test/not-equal-failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');
var tapParser = require('tap-parser');
var common = require('./common');

var getDiag = common.getDiag;
var stripFullStack = common.stripFullStack;

tap.test('not equal failure', function (assert) {
var test = tape.createHarness({ exit : false });
var stream = test.createStream();
var parser = tapParser();
assert.plan(3);

stream.pipe(parser);
stream.pipe(concat(function (body) {
assert.equal(
stripFullStack(body.toString('utf8')),
'TAP version 13\n'
+ '# not equal\n'
+ 'not ok 1 should not be equal\n'
+ ' ---\n'
+ ' operator: notEqual\n'
+ ' expected: 2\n'
+ ' actual: 2\n'
+ ' at: Test.<anonymous> ($TEST/not-equal-failure.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' Error: should not be equal\n'
+ ' [... stack stripped ...]\n'
+ ' at Test.<anonymous> ($TEST/not-equal-failure.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# pass 0\n'
+ '# fail 1\n'
);

assert.deepEqual(getDiag(body), {
operator: 'notEqual',
expected: '2',
actual: '2'
});
}));

parser.once('assert', function (data) {
delete data.diag.stack;
delete data.diag.at;
assert.deepEqual(data, {
ok: false,
id: 1,
name: 'should not be equal',
diag: {
operator: 'notEqual',
expected: '2',
actual: '2'
}
});
});

test("not equal", function (t) {
t.plan(1);
t.notEqual(2, 2);
});
})