Browse Source

test: refactor test-timers-linked-list.js

* check that empty linked lists have identical properties
* `assert.equal()` -> `assert.strictEqual()`
* `var` -> `const`

PR-URL: https://github.com/nodejs/node/pull/8193
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
v6.x
Rich Trott 8 years ago
committed by Evan Lucas
parent
commit
441e8fe566
  1. 61
      test/parallel/test-timers-linked-list.js

61
test/parallel/test-timers-linked-list.js

@ -9,11 +9,11 @@ const internalL = require('internal/linkedlist');
assert.strictEqual(L, internalL); assert.strictEqual(L, internalL);
var list = { name: 'list' }; const list = { name: 'list' };
var A = { name: 'A' }; const A = { name: 'A' };
var B = { name: 'B' }; const B = { name: 'B' };
var C = { name: 'C' }; const C = { name: 'C' };
var D = { name: 'D' }; const D = { name: 'D' };
L.init(list); L.init(list);
@ -23,55 +23,53 @@ L.init(C);
L.init(D); L.init(D);
assert.ok(L.isEmpty(list)); assert.ok(L.isEmpty(list));
assert.equal(null, L.peek(list)); assert.strictEqual(null, L.peek(list));
L.append(list, A); L.append(list, A);
// list -> A // list -> A
assert.equal(A, L.peek(list)); assert.strictEqual(A, L.peek(list));
L.append(list, B); L.append(list, B);
// list -> A -> B // list -> A -> B
assert.equal(A, L.peek(list)); assert.strictEqual(A, L.peek(list));
L.append(list, C); L.append(list, C);
// list -> A -> B -> C // list -> A -> B -> C
assert.equal(A, L.peek(list)); assert.strictEqual(A, L.peek(list));
L.append(list, D); L.append(list, D);
// list -> A -> B -> C -> D // list -> A -> B -> C -> D
assert.equal(A, L.peek(list)); assert.strictEqual(A, L.peek(list));
var x = L.shift(list); assert.strictEqual(A, L.shift(list));
assert.equal(A, x);
// list -> B -> C -> D // list -> B -> C -> D
assert.equal(B, L.peek(list)); assert.strictEqual(B, L.peek(list));
x = L.shift(list); assert.strictEqual(B, L.shift(list));
assert.equal(B, x);
// list -> C -> D // list -> C -> D
assert.equal(C, L.peek(list)); assert.strictEqual(C, L.peek(list));
// B is already removed, so removing it again shouldn't hurt. // B is already removed, so removing it again shouldn't hurt.
L.remove(B); L.remove(B);
// list -> C -> D // list -> C -> D
assert.equal(C, L.peek(list)); assert.strictEqual(C, L.peek(list));
// Put B back on the list // Put B back on the list
L.append(list, B); L.append(list, B);
// list -> C -> D -> B // list -> C -> D -> B
assert.equal(C, L.peek(list)); assert.strictEqual(C, L.peek(list));
L.remove(C); L.remove(C);
// list -> D -> B // list -> D -> B
assert.equal(D, L.peek(list)); assert.strictEqual(D, L.peek(list));
L.remove(B); L.remove(B);
// list -> D // list -> D
assert.equal(D, L.peek(list)); assert.strictEqual(D, L.peek(list));
L.remove(D); L.remove(D);
// list // list
assert.equal(null, L.peek(list)); assert.strictEqual(null, L.peek(list));
assert.ok(L.isEmpty(list)); assert.ok(L.isEmpty(list));
@ -79,7 +77,7 @@ assert.ok(L.isEmpty(list));
L.append(list, D); L.append(list, D);
// list -> D // list -> D
assert.equal(D, L.peek(list)); assert.strictEqual(D, L.peek(list));
L.append(list, C); L.append(list, C);
L.append(list, B); L.append(list, B);
@ -90,16 +88,16 @@ L.append(list, A);
L.append(list, C); L.append(list, C);
// list -> D -> B -> A -> C // list -> D -> B -> A -> C
assert.equal(D, L.shift(list)); assert.strictEqual(D, L.shift(list));
// list -> B -> A -> C // list -> B -> A -> C
assert.equal(B, L.peek(list)); assert.strictEqual(B, L.peek(list));
assert.equal(B, L.shift(list)); assert.strictEqual(B, L.shift(list));
// list -> A -> C // list -> A -> C
assert.equal(A, L.peek(list)); assert.strictEqual(A, L.peek(list));
assert.equal(A, L.shift(list)); assert.strictEqual(A, L.shift(list));
// list -> C // list -> C
assert.equal(C, L.peek(list)); assert.strictEqual(C, L.peek(list));
assert.equal(C, L.shift(list)); assert.strictEqual(C, L.shift(list));
// list // list
assert.ok(L.isEmpty(list)); assert.ok(L.isEmpty(list));
@ -107,4 +105,7 @@ const list2 = L.create();
const list3 = L.create(); const list3 = L.create();
assert.ok(L.isEmpty(list2)); assert.ok(L.isEmpty(list2));
assert.ok(L.isEmpty(list3)); assert.ok(L.isEmpty(list3));
assert.ok(list2 != list3);
// Objects should have identical keys/properties, but be different objects.
assert.deepStrictEqual(list2, list3);
assert.notStrictEqual(list2, list3);

Loading…
Cancel
Save