Skip to content

Commit

Permalink
[Tests] add tests for Object.create(null)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold authored and ljharb committed Jul 1, 2017
1 parent b8c179c commit ed266e8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test('strict equal', function (t) {

test('non-objects', function (t) {
t.ok(equal(3, 3));
t.ok(equal(3, 3, { strict: true }));
t.ok(equal('beep', 'beep'));
t.ok(equal('3', 3));
t.notOk(equal('3', 3, { strict: true }));
Expand Down Expand Up @@ -229,7 +230,7 @@ test('zeroes', function (t) {
t.end();
});

test('test objects', { skip: !Object.create }, function (t) {
test('Object.create', { skip: !Object.create }, function (t) {
var a = { a: 'A' };
var b = Object.create(a);
b.b = 'B';
Expand All @@ -245,6 +246,16 @@ test('test objects', { skip: !Object.create }, function (t) {
t.end();
});

test('Object.create(null)', { skip: !Object.create }, function (t) {
t.ok(equal(Object.create(null), Object.create(null)), 'two empty null objects are deep equal');
t.ok(equal(Object.create(null), Object.create(null), { strict: true }), 'strict: two empty null objects are deep equal');

t.ok(equal(Object.create(null, { a: { value: 'b' } }), Object.create(null, { a: { value: 'b' } })), 'two null objects are deep equal');
t.ok(equal(Object.create(null, { a: { value: 'b' } }), Object.create(null, { a: { value: 'b' } }), { strict: true }), 'strict: two null objects are deep equal');

t.end();
});

test('regexes vs dates', function (t) {
var d = new Date(1387585278000);
var r = /abc/;
Expand Down

0 comments on commit ed266e8

Please sign in to comment.