From da874590a6313f7303bec8c83953b98a5f7f506d Mon Sep 17 00:00:00 2001 From: richnologies Date: Fri, 20 Jan 2017 12:51:55 +0100 Subject: [PATCH] test: improve test-assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add RegExp to check assert throws the expected AssertionErrors. For the one with multiple flags is ok to hardcode the flags since the spec indicates the ordering will always be `gim`: Refs: http://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags PR-URL: https://github.com/nodejs/node/pull/10916 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Italo A. Casas Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-assert.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 8ee1989cf7423e..8fa1e0407172fa 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -216,11 +216,26 @@ assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepStrictEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/igm, /a/im)); +assert.throws( + makeBlock(a.deepStrictEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepStrictEqual \/a\/im$/ +); { const re1 = /a/;