From e1bbaf64958d21c6673148b9e56f3cf62808c88e Mon Sep 17 00:00:00 2001 From: Adri Van Houdt Date: Mon, 6 Nov 2017 16:49:07 +0000 Subject: [PATCH 1/4] test: better wording on assertion errors --- test/parallel/test-repl-reset-event.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-repl-reset-event.js b/test/parallel/test-repl-reset-event.js index e9772e3462cc83..c7cafc7e1a1fe1 100644 --- a/test/parallel/test-repl-reset-event.js +++ b/test/parallel/test-repl-reset-event.js @@ -25,6 +25,7 @@ common.globalCheck = false; const assert = require('assert'); const repl = require('repl'); +const util = require('util'); // Create a dummy stream that does nothing const dummy = new common.ArrayStream(); @@ -38,11 +39,11 @@ function testReset(cb) { r.context.foo = 42; r.on('reset', common.mustCall(function(context) { assert(!!context, 'REPL did not emit a context with reset event'); - assert.strictEqual(context, r.context, 'REPL emitted incorrect context'); + assert.strictEqual(context, r.context, `REPL emitted incorrect context. context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`); assert.strictEqual( context.foo, undefined, - 'REPL emitted the previous context, and is not using global as context' + `REPL emitted the previous context, and is not using global as context. context.foo is ${context.foo}, expected undefined.` ); context.foo = 42; cb(); @@ -61,7 +62,7 @@ function testResetGlobal() { assert.strictEqual( context.foo, 42, - '"foo" property is missing from REPL using global as context' + `"foo" property is missing or different from REPL using global as context. context.foo is ${context.foo}, expected 42.` ); })); r.resetContext(); From 7ef44e930d9895122512eee5d1e4dab072e5a0b8 Mon Sep 17 00:00:00 2001 From: Adri Van Houdt Date: Mon, 6 Nov 2017 17:02:21 +0000 Subject: [PATCH 2/4] test: make assertions clearer --- test/parallel/test-repl-reset-event.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-repl-reset-event.js b/test/parallel/test-repl-reset-event.js index c7cafc7e1a1fe1..a171926e787772 100644 --- a/test/parallel/test-repl-reset-event.js +++ b/test/parallel/test-repl-reset-event.js @@ -39,11 +39,13 @@ function testReset(cb) { r.context.foo = 42; r.on('reset', common.mustCall(function(context) { assert(!!context, 'REPL did not emit a context with reset event'); - assert.strictEqual(context, r.context, `REPL emitted incorrect context. context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`); + assert.strictEqual(context, r.context, 'REPL emitted incorrect context.' + + `context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`); assert.strictEqual( context.foo, undefined, - `REPL emitted the previous context, and is not using global as context. context.foo is ${context.foo}, expected undefined.` + 'REPL emitted the previous context, and is not using global as context.' + + `context.foo is ${context.foo}, expected undefined.` ); context.foo = 42; cb(); @@ -62,7 +64,8 @@ function testResetGlobal() { assert.strictEqual( context.foo, 42, - `"foo" property is missing or different from REPL using global as context. context.foo is ${context.foo}, expected 42.` + '"foo" property is different from REPL using global as context.' + + `context.foo is ${context.foo}, expected 42.` ); })); r.resetContext(); From 15f8a1fe2575e20eaa312d3c3b63b80d3acf720a Mon Sep 17 00:00:00 2001 From: Adri Van Houdt Date: Mon, 4 Dec 2017 09:44:29 +0100 Subject: [PATCH 3/4] test: add space at the end --- test/parallel/test-repl-reset-event.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-repl-reset-event.js b/test/parallel/test-repl-reset-event.js index a171926e787772..5e209d589166ed 100644 --- a/test/parallel/test-repl-reset-event.js +++ b/test/parallel/test-repl-reset-event.js @@ -39,12 +39,12 @@ function testReset(cb) { r.context.foo = 42; r.on('reset', common.mustCall(function(context) { assert(!!context, 'REPL did not emit a context with reset event'); - assert.strictEqual(context, r.context, 'REPL emitted incorrect context.' + + assert.strictEqual(context, r.context, 'REPL emitted incorrect context. ' + `context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`); assert.strictEqual( context.foo, undefined, - 'REPL emitted the previous context, and is not using global as context.' + + 'REPL emitted the previous context, and is not using global as context. ' + `context.foo is ${context.foo}, expected undefined.` ); context.foo = 42; @@ -64,7 +64,7 @@ function testResetGlobal() { assert.strictEqual( context.foo, 42, - '"foo" property is different from REPL using global as context.' + + '"foo" property is different from REPL using global as context. ' + `context.foo is ${context.foo}, expected 42.` ); })); From ed044ac97bd0c132360c333a1fc0cadaebfd3c8f Mon Sep 17 00:00:00 2001 From: Adri Van Houdt Date: Wed, 6 Dec 2017 11:12:23 +0100 Subject: [PATCH 4/4] test: remove comma for linter --- test/parallel/test-repl-reset-event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-repl-reset-event.js b/test/parallel/test-repl-reset-event.js index 5e209d589166ed..83ab7fd6a3ec52 100644 --- a/test/parallel/test-repl-reset-event.js +++ b/test/parallel/test-repl-reset-event.js @@ -44,7 +44,7 @@ function testReset(cb) { assert.strictEqual( context.foo, undefined, - 'REPL emitted the previous context, and is not using global as context. ' + + 'REPL emitted the previous context and is not using global as context. ' + `context.foo is ${context.foo}, expected undefined.` ); context.foo = 42;