Skip to content

Commit 12ff395

Browse files
Trotttargos
authored andcommitted
assert: remove internal errorCache property
The internal assert module exposed an errorCache property solely for testing. It is no longer necessary. Remove it. PR-URL: #23304 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent df54db6 commit 12ff395

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/assert.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ const { codes: {
2626
ERR_INVALID_ARG_TYPE,
2727
ERR_INVALID_RETURN_VALUE
2828
} } = require('internal/errors');
29-
const { AssertionError, errorCache } = require('internal/assert');
29+
const { AssertionError } = require('internal/assert');
3030
const { openSync, closeSync, readSync } = require('fs');
3131
const { inspect, types: { isPromise, isRegExp } } = require('util');
3232
const { EOL } = require('internal/constants');
3333
const { NativeModule } = require('internal/bootstrap/loaders');
3434

35+
const errorCache = new Map();
36+
3537
let isDeepEqual;
3638
let isDeepStrictEqual;
3739
let parseExpressionAt;

lib/internal/assert.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,5 @@ class AssertionError extends Error {
271271
}
272272

273273
module.exports = {
274-
AssertionError,
275-
errorCache: new Map()
274+
AssertionError
276275
};

test/parallel/test-assert-builtins-not-read-from-filesystem.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ if (process.argv[2] !== 'child') {
1919
e.emit('hello', false);
2020
} catch (err) {
2121
const frames = err.stack.split('\n');
22-
const [, filename, , ] = frames[1].match(/\((.+):(\d+):(\d+)\)/);
22+
const [, filename, line, column] = frames[1].match(/\((.+):(\d+):(\d+)\)/);
2323
// Spawn a child process to avoid the error having been cached in the assert
2424
// module's `errorCache` Map.
2525

2626
const { output, status, error } =
2727
spawnSync(process.execPath,
28-
[process.argv[1], 'child', filename],
28+
[process.argv[1], 'child', filename, line, column],
2929
{ cwd: tmpdir.path, env: process.env });
3030
assert.ifError(error);
3131
assert.strictEqual(status, 0, `Exit code: ${status}\n${output}`);

0 commit comments

Comments
 (0)