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

Commit

Permalink
test: cleanup with upstream
Browse files Browse the repository at this point in the history
Cleaned up a bunch of inconsistencies with the upstream tests.
  • Loading branch information
kfarnung committed Aug 12, 2017
1 parent 85058b2 commit a89c041
Show file tree
Hide file tree
Showing 27 changed files with 169 additions and 168 deletions.
1 change: 0 additions & 1 deletion test/addons-napi/test_async/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const common = require('../../common');
const assert = require('assert');
const child_process = require('child_process');

const test_async = require(`./build/${common.buildType}/test_async`);

const testException = 'test_async_cb_exception';
Expand Down
9 changes: 4 additions & 5 deletions test/inspector/test-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ function checkVersion(err, response) {
}

function checkBadPath(err, response) {
assert(err instanceof SyntaxError, 'Expected SyntaxError');
assert(err instanceof SyntaxError);
assert(
common.engineSpecificMessage({
v8: /Unexpected token/,
chakracore: /JSON\.parse Error: Invalid character at position:1/
}).test(err.message),
'Unexpected message: ' + err.message);
assert(/WebSockets request was expected/.test(err.response),
'Unexpected response: ' + err.response);
}).test(err.message)
);
assert(/WebSockets request was expected/.test(err.response));
}

function expectMainScriptSource(result) {
Expand Down
8 changes: 0 additions & 8 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ test-npm-install: PASS,FLAKY

[$system==freebsd]

# fs-watch currently needs special configuration on AIX and we
# want to improve under https://github.com/nodejs/node/issues/5085.
# Tests are disabled so CI can be green and we can spot other
# regressions until this work is complete
[$system==aix]
test-fs-watch-enoent : FAIL, PASS
test-fs-watch-encoding : FAIL, PASS

[$jsEngine==chakracore]
test-assert-checktag : PASS,FLAKY
test-async-hooks-disable-during-promise : PASS,FLAKY
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-buffer-slow.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ try {
v8: 'Array buffer allocation failed',
chakracore: 'Invalid offset/length when creating typed array'
}));

}

// should work with number-coercible values
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-domain-abort-on-uncaught.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (common.isChakraEngine) {
'on v8-option --abort-on-uncaught-exception');
return;
}

const tests = [
function nextTick() {
const d = domain.create();
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ d.on('error', function(er) {

const typeErrMsg = common.engineSpecificMessage({
v8: "Cannot read property 'isDirectory' of undefined",
chakracore: "Unable to get property 'isDirectory' of undefined or\
null reference"
chakracore: "Unable to get property 'isDirectory' of undefined or" +
' null reference'
});

switch (er_message) {
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const assert = require('assert');
const path = require('path');
const childProcess = require('child_process');


const nodeBinary = process.argv[0];

const preloadOption = (preloads) => {
Expand Down
27 changes: 14 additions & 13 deletions test/parallel/test-querystring-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ assert.strictEqual(
);

// toString is not callable, must throw an error
assert.throws(() => qs.escape({toString: 5}),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert object to primitive value$/,
chakracore: /^TypeError: String expected$/
}));
assert.throws(
() => qs.escape({toString: 5}),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert object to primitive value$/,
chakracore: /^TypeError: String expected$/
})
);

// should use valueOf instead of non-callable toString
assert.strictEqual(qs.escape({toString: 5, valueOf: () => 'test'}), 'test');

const chakraSymbolTypeError =
/^TypeError: Object doesn't support property or method 'ToString'$/;

assert.throws(() => qs.escape(Symbol('test')),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakraSymbolTypeError
}));
assert.throws(
() => qs.escape(Symbol('test')),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: /^TypeError: Object doesn't support property or method 'ToString'$/
})
);
32 changes: 14 additions & 18 deletions test/parallel/test-url-format-whatwg.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,20 @@ assert.strictEqual(
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

// Unicode conversion in node code is dependent on
// v8's i18n support which is disabled for chakracore
if (!common.isChakraEngine) {
assert.strictEqual(
url.format(myURL, { unicode: true }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, { unicode: 1 }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, { unicode: {} }),
'http://理容ナカムラ.com/a?a=b#c'
);
}
assert.strictEqual(
url.format(myURL, { unicode: true }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, { unicode: 1 }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, { unicode: {} }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, { unicode: false }),
Expand Down
14 changes: 7 additions & 7 deletions test/parallel/test-url-parse-invalid-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const errMessage = /^TypeError: Parameter "url" must be a string, not (?:undefin
assert.throws(() => { url.parse(val); }, errMessage);
});

const engineSpecificMalformedUrlError =
common.engineSpecificMessage({
v8: /^URIError: URI malformed$/,
chakracore: /^URIError: The URI to be decoded is not a valid encoding$/
});

assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, engineSpecificMalformedUrlError);
assert.throws(
() => { url.parse('http://%E0%A4%A@fail'); },
common.engineSpecificMessage({
v8: /^URIError: URI malformed$/,
chakracore: /^URIError: The URI to be decoded is not a valid encoding$/
})
);
4 changes: 1 addition & 3 deletions test/parallel/test-util-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ try {
binding.getHiddenValue(err, kArrowMessagePrivateSymbolIndex);
}

if (!common.isChakraEngine) { // chakra does not show script/source
assert(/bad_syntax\.js:1/.test(arrowMessage));
}
assert(/bad_syntax\.js:1/.test(arrowMessage));
4 changes: 1 addition & 3 deletions test/parallel/test-v8-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ const assert = require('assert');
const v8 = require('v8');
const vm = require('vm');

if (common.isChakraEngine) {
if (common.isChakraEngine)
common.skip('This test is disabled for chakra engine.');
return;
}

// Note: changing V8 flags after an isolate started is not guaranteed to work.
// Specifically here, V8 may cache compiled scripts between the flip of the
Expand Down
4 changes: 1 addition & 3 deletions test/parallel/test-v8-version-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ const common = require('../common');
const assert = require('assert');
const v8 = require('v8');

if (common.isChakraEngine) {
if (common.isChakraEngine)
common.skip('This test is disabled for chakra engine.');
return;
}

const versionTag1 = v8.cachedDataVersionTag();
assert.strictEqual(typeof versionTag1, 'number');
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-vm-debug-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ assert.throws(
common.engineSpecificMessage({
v8: /RangeError/,
chakracore: /Error: Out of stack space/
}));
})
);

assert.strictEqual(typeof vm.runInDebugContext('this'), 'object');
assert.strictEqual(typeof vm.runInDebugContext('Debug'), 'object');
Expand Down
15 changes: 9 additions & 6 deletions test/parallel/test-vm-new-script-new-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ const Script = require('vm').Script;

{
const script = new Script('');
assert.throws(function() {
script.runInNewContext.call('\'hello\';');
}, common.engineSpecificMessage({
v8: /^TypeError: this\.runInContext is not a function$/,
chakracore: /^TypeError: Object doesn't support property or method 'runInContext'$/
}));
assert.throws(
function() {
script.runInNewContext.call('\'hello\';');
},
common.engineSpecificMessage({
v8: /^TypeError: this\.runInContext is not a function$/,
chakracore: /^TypeError: Object doesn't support property or method 'runInContext'$/
})
);
}
4 changes: 2 additions & 2 deletions test/parallel/test-vm-syntax-error-stderr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ p.stderr.on('data', function(data) {
process.on('exit', function() {
assert(/BEGIN CERT/.test(output));
assert(/^\s+\^/m.test(output));
common.engineSpecificMessage({
assert(common.engineSpecificMessage({
v8: /Invalid left-hand side expression in prefix operation/,
chakracore: /SyntaxError: Expected ';'/
}).test(output);
}).test(output));
});
26 changes: 14 additions & 12 deletions test/parallel/test-whatwg-url-searchparams-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,20 @@ test(function() {
valueOf() { throw new Error('valueOf'); }
};
const sym = Symbol();
const chakracoreSymbolErrorRegex =
/^TypeError: Object doesn't support property or method 'ToString'/;
assert.throws(() => params.set(obj, 'b'), /^Error: toString$/);
assert.throws(() => params.set('a', obj), /^Error: toString$/);
assert.throws(() => params.set(sym, 'b'),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(() => params.set('a', sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(
() => params.set(sym, 'b'),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: /^TypeError: Object doesn't support property or method 'ToString'/
})
);
assert.throws(
() => params.set('a', sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: /^TypeError: Object doesn't support property or method 'ToString'/
})
);
}
62 changes: 36 additions & 26 deletions test/parallel/test-whatwg-url-searchparams-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,33 +245,43 @@ function makeIterableFunc(array) {
const toStringError = /^Error: toString$/;
const symbolError = /^TypeError: Cannot convert a Symbol value to a string$/;
const chakracoreSymbolErrorRegex =
/^TypeError: Object doesn't support property or method 'ToString'/;
/^TypeError: Object doesn't support property or method 'ToString'/;

assert.throws(() => new URLSearchParams({ a: obj }), toStringError);
assert.throws(() => new URLSearchParams([['a', obj]]), toStringError);
assert.throws(() => new URLSearchParams(sym),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(() => new URLSearchParams({ [sym]: 'a' }),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(() => new URLSearchParams({ a: sym }),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(() => new URLSearchParams([[sym, 'a']]),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(() => new URLSearchParams([['a', sym]]),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(
() => new URLSearchParams(sym),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
})
);
assert.throws(
() => new URLSearchParams({ [sym]: 'a' }),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
})
);
assert.throws(
() => new URLSearchParams({ a: sym }),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
})
);
assert.throws(
() => new URLSearchParams([[sym, 'a']]),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
})
);
assert.throws(
() => new URLSearchParams([['a', sym]]),
common.engineSpecificMessage({
v8: symbolError,
chakracore: chakracoreSymbolErrorRegex
})
);
}
14 changes: 7 additions & 7 deletions test/parallel/test-whatwg-url-searchparams-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ test(function() {
valueOf() { throw new Error('valueOf'); }
};
const sym = Symbol();
const chakracoreSymbolErrorRegex =
/^TypeError: Object doesn't support property or method 'ToString'/;
assert.throws(() => params.delete(obj), /^Error: toString$/);
assert.throws(() => params.delete(sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(
() => params.delete(sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: /^TypeError: Object doesn't support property or method 'ToString'/
})
);
}

// https://github.com/nodejs/node/issues/10480
Expand Down
14 changes: 7 additions & 7 deletions test/parallel/test-whatwg-url-searchparams-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ test(function() {
valueOf() { throw new Error('valueOf'); }
};
const sym = Symbol();
const chakracoreSymbolErrorRegex =
/^TypeError: Object doesn't support property or method 'ToString'/;
assert.throws(() => params.get(obj), /^Error: toString$/);
assert.throws(() => params.get(sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: chakracoreSymbolErrorRegex
}));
assert.throws(
() => params.get(sym),
common.engineSpecificMessage({
v8: /^TypeError: Cannot convert a Symbol value to a string$/,
chakracore: /^TypeError: Object doesn't support property or method 'ToString'/
})
);
}
Loading

0 comments on commit a89c041

Please sign in to comment.