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);
var list = { name: 'list' };
var A = { name: 'A' };
var B = { name: 'B' };
var C = { name: 'C' };
var D = { name: 'D' };
const list = { name: 'list' };
const A = { name: 'A' };
const B = { name: 'B' };
const C = { name: 'C' };
const D = { name: 'D' };
L.init(list);
@ -23,55 +23,53 @@ L.init(C);
L.init(D);
assert.ok(L.isEmpty(list));
assert.equal(null, L.peek(list));
assert.strictEqual(null, L.peek(list));
L.append(list, A);
// list -> A
assert.equal(A, L.peek(list));
assert.strictEqual(A, L.peek(list));
L.append(list, B);
// list -> A -> B
assert.equal(A, L.peek(list));
assert.strictEqual(A, L.peek(list));
L.append(list, C);
// list -> A -> B -> C
assert.equal(A, L.peek(list));
assert.strictEqual(A, L.peek(list));
L.append(list, D);
// list -> A -> B -> C -> D
assert.equal(A, L.peek(list));
assert.strictEqual(A, L.peek(list));
var x = L.shift(list);
assert.equal(A, x);
assert.strictEqual(A, L.shift(list));
// list -> B -> C -> D
assert.equal(B, L.peek(list));
assert.strictEqual(B, L.peek(list));
x = L.shift(list);
assert.equal(B, x);
assert.strictEqual(B, L.shift(list));
// 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.
L.remove(B);
// list -> C -> D
assert.equal(C, L.peek(list));
assert.strictEqual(C, L.peek(list));
// Put B back on the list
L.append(list, B);
// list -> C -> D -> B
assert.equal(C, L.peek(list));
assert.strictEqual(C, L.peek(list));
L.remove(C);
// list -> D -> B
assert.equal(D, L.peek(list));
assert.strictEqual(D, L.peek(list));
L.remove(B);
// list -> D
assert.equal(D, L.peek(list));
assert.strictEqual(D, L.peek(list));
L.remove(D);
// list
assert.equal(null, L.peek(list));
assert.strictEqual(null, L.peek(list));
assert.ok(L.isEmpty(list));
@ -79,7 +77,7 @@ assert.ok(L.isEmpty(list));
L.append(list, D);
// list -> D
assert.equal(D, L.peek(list));
assert.strictEqual(D, L.peek(list));
L.append(list, C);
L.append(list, B);
@ -90,16 +88,16 @@ L.append(list, A);
L.append(list, C);
// list -> D -> B -> A -> C
assert.equal(D, L.shift(list));
assert.strictEqual(D, L.shift(list));
// list -> B -> A -> C
assert.equal(B, L.peek(list));
assert.equal(B, L.shift(list));
assert.strictEqual(B, L.peek(list));
assert.strictEqual(B, L.shift(list));
// list -> A -> C
assert.equal(A, L.peek(list));
assert.equal(A, L.shift(list));
assert.strictEqual(A, L.peek(list));
assert.strictEqual(A, L.shift(list));
// list -> C
assert.equal(C, L.peek(list));
assert.equal(C, L.shift(list));
assert.strictEqual(C, L.peek(list));
assert.strictEqual(C, L.shift(list));
// list
assert.ok(L.isEmpty(list));
@ -107,4 +105,7 @@ const list2 = L.create();
const list3 = L.create();
assert.ok(L.isEmpty(list2));
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