From ae0ef11b1988ebeeaa1a0fed9c10610273d37268 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 25 Jun 2016 15:18:04 -0700 Subject: [PATCH 1/2] test: test isFullWidthCodePoint with invalid input Code coverage information shows that we are only testing the happy path for the internal readline `isFullWidthCodePoint()` function. Test it with invalid input. --- test/parallel/test-readline-interface.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index c8cb4c96749e2d..02d2dd5d7f163e 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -327,6 +327,9 @@ function isWarned(emitter) { rli.close(); } + // isFullWidthCodePoint() should return false for non-numeric values + assert.strictEqual(internalReadline.isFullWidthCodePoint('あ'), false); + // wide characters should be treated as two columns. assert.equal(internalReadline.isFullWidthCodePoint('a'.charCodeAt(0)), false); assert.equal(internalReadline.isFullWidthCodePoint('あ'.charCodeAt(0)), true); From 6d71146675afafdd68b41c7ab35a30172cabbe77 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 27 Jun 2016 17:03:25 -0700 Subject: [PATCH 2/2] squash: add more non-numeric primitives --- test/parallel/test-readline-interface.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 02d2dd5d7f163e..b09870b0dd7b85 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -328,7 +328,9 @@ function isWarned(emitter) { } // isFullWidthCodePoint() should return false for non-numeric values - assert.strictEqual(internalReadline.isFullWidthCodePoint('あ'), false); + [true, false, null, undefined, {}, [], 'あ'].forEach((v) => { + assert.strictEqual(internalReadline.isFullWidthCodePoint('あ'), false); + }); // wide characters should be treated as two columns. assert.equal(internalReadline.isFullWidthCodePoint('a'.charCodeAt(0)), false);