aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-console.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-16 01:40:28 -0200
committerRuben Bridgewater <ruben@bridgewater.de>2017-12-26 10:46:27 +0100
commit15d880bcb62c628f1e7c3cc7baf659a63b312c7c (patch)
tree22d31adf9129d836fc1236eb8bc4b8979dc0239a /test/parallel/test-console.js
parent9ca4ab13171f2148a986062ac564161a1f6e124f (diff)
downloadandroid-node-v8-15d880bcb62c628f1e7c3cc7baf659a63b312c7c.tar.gz
android-node-v8-15d880bcb62c628f1e7c3cc7baf659a63b312c7c.tar.bz2
android-node-v8-15d880bcb62c628f1e7c3cc7baf659a63b312c7c.zip
console: make .assert standard compliant
The standard does not throw and has no stack trace. See https://console.spec.whatwg.org/#assert PR-URL: https://github.com/nodejs/node/pull/17706 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-console.js')
-rw-r--r--test/parallel/test-console.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js
index c0ca672eba..b789d05ee2 100644
--- a/test/parallel/test-console.js
+++ b/test/parallel/test-console.js
@@ -140,6 +140,16 @@ console.timeEnd();
console.time(NaN);
console.timeEnd(NaN);
+assert.doesNotThrow(() => {
+ console.assert(false, '%s should', 'console.assert', 'not throw');
+ assert.strictEqual(errStrings[errStrings.length - 1],
+ 'Assertion failed: console.assert should not throw\n');
+});
+
+assert.doesNotThrow(() => {
+ console.assert(true, 'this should not throw');
+});
+
assert.strictEqual(strings.length, process.stdout.writeTimes);
assert.strictEqual(errStrings.length, process.stderr.writeTimes);
common.restoreStdout();
@@ -200,17 +210,6 @@ assert.ok(/^NaN: \d+\.\d{3}ms$/.test(strings.shift().trim()));
assert.strictEqual(errStrings.shift().split('\n').shift(),
'Trace: This is a {"formatted":"trace"} 10 foo');
-common.expectsError(() => {
- console.assert(false, 'should throw');
-}, {
- code: 'ERR_ASSERTION',
- message: /^should throw$/
-});
-
-assert.doesNotThrow(() => {
- console.assert(true, 'this should not throw');
-});
-
// hijack stderr to catch `process.emitWarning` which is using
// `process.nextTick`
common.hijackStderr(common.mustCall(function(data) {