Skip to content

Commit

Permalink
assert: remove internal errorCache property
Browse files Browse the repository at this point in the history
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 <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Oct 17, 2018
1 parent 6d2bbb3 commit 5217c52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ const { codes: {
ERR_INVALID_ARG_VALUE,
ERR_INVALID_RETURN_VALUE
} } = require('internal/errors');
const { AssertionError, errorCache } = require('internal/assert');
const { AssertionError } = require('internal/assert');
const { openSync, closeSync, readSync } = require('fs');
const { inspect, types: { isPromise, isRegExp } } = require('util');
const { EOL } = require('internal/constants');
const { NativeModule } = require('internal/bootstrap/loaders');

const errorCache = new Map();

let isDeepEqual;
let isDeepStrictEqual;
let parseExpressionAt;
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,5 @@ class AssertionError extends Error {
}

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

const { output, status, error } =
spawnSync(process.execPath,
[process.argv[1], 'child', filename],
[process.argv[1], 'child', filename, line, column],
{ cwd: tmpdir.path, env: process.env });
assert.ifError(error);
assert.strictEqual(status, 0, `Exit code: ${status}\n${output}`);
Expand Down

0 comments on commit 5217c52

Please sign in to comment.