From 441e8fe566e6e1bbfdc9ac84098e49568d203d34 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Aug 2016 16:39:19 -0700 Subject: [PATCH] test: refactor test-timers-linked-list.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Franziska Hinkelmann --- test/parallel/test-timers-linked-list.js | 61 ++++++++++++------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/test/parallel/test-timers-linked-list.js b/test/parallel/test-timers-linked-list.js index 4ec7770cfaa8ff..c89c3e23c6d0d0 100644 --- a/test/parallel/test-timers-linked-list.js +++ b/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);