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 targos committed Oct 10, 2018
1 parent df54db6 commit 12ff395
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
Expand Up @@ -26,12 +26,14 @@ const { codes: {
ERR_INVALID_ARG_TYPE,

This comment was marked as off-topic.

Copy link
@meemoooo

meemoooo Oct 11, 2018

All

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
Expand Up @@ -271,6 +271,5 @@ class AssertionError extends Error {
}

module.exports = {
AssertionError,
errorCache: new Map()
AssertionError
};
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 12ff395

Please sign in to comment.