Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Fixed assert messages and skipped three more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Irina Yatsenko authored and kfarnung committed Jul 25, 2018
1 parent c846a16 commit 22f03cf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function findColumn(fd, column, code) {
if (code.length > column + 100) {
try {
return parseCode(code, column);
} catch {
} catch (e) {
// End recursion in case no code could be parsed. The expression should
// have been found after 2500 characters, so stop trying.
if (code.length - column > 2500) {
Expand Down
15 changes: 14 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ test-intl : SKIP
test-memory-usage : SKIP
test-module-main-extension-lookup : SKIP
test-performance-function : SKIP
test-performance-gc : SKIP
test-postmortem-metadata: SKIP
test-process-env-symbols : SKIP
test-promises-unhandled-symbol-rejections : SKIP
Expand All @@ -75,6 +74,11 @@ test-repl-sigint : SKIP
test-repl-tab-complete : SKIP
test-string-decoder : SKIP

# Depends on V8's custom GC behaviour
test-performance-gc : SKIP
test-common-gc : SKIP
test-net-connect-memleak : SKIP

# ChakraCore does not support the chrome tracing framework
test-trace-events-all : SKIP
test-trace-events-api : SKIP
Expand Down Expand Up @@ -243,6 +247,15 @@ test-vm-createcacheddata : SKIP
# Issue: https://github.com/nodejs/node-chakracore/issues/565
test-atomics-notify : SKIP

# These tests rely on V8's custom heap dumping and validation
test-heapdump-dns : SKIP
test-heapdump-fs-promise : SKIP
test-heapdump-http2 : SKIP
test-heapdump-inspector : SKIP
test-heapdump-tls : SKIP
test-heapdump-worker : SKIP
test-heapdump-zlib : SKIP

[$jsEngine==chakracore && $arch==x64]
# These tests are failing for Node-Chakracore and should eventually be fixed
test-buffer-includes : SKIP
Expand Down
25 changes: 22 additions & 3 deletions test/parallel/test-assert-first-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,41 @@

// Verify that asserting in the very first line produces the expected result.

require('../common');
const common = require('../common');
const assert = require('assert');
const { path } = require('../common/fixtures');

// https://github.com/nodejs/node/pull/17581 added functionality to
// lib/assert.js that made assert messages much nicer.
// However, it relies on non-standard/undocumented V8 error APIs.
// Thus, there is a modification to that file to fall back to the old
// path for ChakraCore

function engineSpecificAssert(v8, cc) {
return common.engineSpecificMessage({
v8: `The expression evaluated to a falsy value:\n\n ${v8}`,
chakracore: cc
});
}

assert.throws(
() => require(path('assert-first-line')),
{
name: 'AssertionError [ERR_ASSERTION]',
message: "The expression evaluated to a falsy value:\n\n ässört.ok('')\n"
message: engineSpecificAssert(
'ässört.ok(\'\')\n',
'\'\' == true'
)
}
);

assert.throws(
() => require(path('assert-long-line')),
{
name: 'AssertionError [ERR_ASSERTION]',
message: "The expression evaluated to a falsy value:\n\n assert.ok('')\n"
message: engineSpecificAssert(
'assert.ok(\'\')\n',
'\'\' == true'
)
}
);
17 changes: 12 additions & 5 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,10 @@ common.expectsError(
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'The expression evaluated to a falsy value:\n\n ' +
'ok(null, undefined)\n'
message: engineSpecificAssert(
'assert(null, undefined)\n',
'null == true'
)
}
);

Expand All @@ -801,8 +803,10 @@ common.expectsError(
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'The expression evaluated to a falsy value:\n\n ' +
'assert[\'ok\']["apply"](null, [0])\n'
message: engineSpecificAssert(
'assert[\'ok\']["apply"](null, [0])\n',
'0 == true'
)
}
);

Expand All @@ -814,7 +818,10 @@ common.expectsError(
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'The expression evaluated to a falsy value:\n\n fn(value)\n'
message: engineSpecificAssert(
'fn(value)\n',
'false == true'
)
}
);

Expand Down

0 comments on commit 22f03cf

Please sign in to comment.