Skip to content

Commit 7b76f82

Browse files
Trottjasnell
authored andcommitted
test: enhance test-common.js
* refactor test-common.js so that global leak detection does not need to be disabled * add test for common.fail() PR-URL: #11433 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent bc44d2c commit 7b76f82

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/parallel/test-common.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22
const common = require('../common');
33
const assert = require('assert');
44

5-
common.globalCheck = false;
5+
6+
// test for leaked global detection
67
global.gc = 42; // Not a valid global unless --expose_gc is set.
78
assert.deepStrictEqual(common.leakedGlobals(), ['gc']);
9+
delete global.gc;
10+
811

12+
// common.mustCall() tests
913
assert.throws(function() {
1014
common.mustCall(function() {}, 'foo');
1115
}, /^TypeError: Invalid expected value: foo$/);
1216

1317
assert.throws(function() {
1418
common.mustCall(function() {}, /foo/);
1519
}, /^TypeError: Invalid expected value: \/foo\/$/);
20+
21+
22+
// common.fail() tests
23+
assert.throws(
24+
() => { common.fail('fhqwhgads'); },
25+
/^AssertionError: fhqwhgads$/
26+
);

0 commit comments

Comments
 (0)