Skip to content

Commit

Permalink
Don't use internal Node.js functionality in test/parallel/test-assert.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed Apr 16, 2019
1 parent e48ac96 commit 002f90a
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
const common = require('../common');
const assert = require('assert');
const { inspect } = require('util');
const { internalBinding } = require('internal/test/binding');
// [browserify]
// const { internalBinding } = require('internal/test/binding');
const a = assert;

// Disable colored output to prevent color codes from breaking assertion
Expand Down Expand Up @@ -656,36 +657,38 @@ common.expectsError(
}
);

{
// Test caching.
const fs = internalBinding('fs');
const tmp = fs.close;
fs.close = common.mustCall(tmp, 1);
function throwErr() {
assert(
(Buffer.from('test') instanceof Error)
);
}
common.expectsError(
() => throwErr(),
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'The expression evaluated to a falsy value:\n\n ' +
"assert(\n (Buffer.from('test') instanceof Error)\n )\n"
}
);
common.expectsError(
() => throwErr(),
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
message: 'The expression evaluated to a falsy value:\n\n ' +
"assert(\n (Buffer.from('test') instanceof Error)\n )\n"
}
);
fs.close = tmp;
}
// [browserify]
// This test uses internal Node.js functionality so we have to skip it.
// {
// // Test caching.
// const fs = internalBinding('fs');
// const tmp = fs.close;
// fs.close = common.mustCall(tmp, 1);
// function throwErr() {
// assert(
// (Buffer.from('test') instanceof Error)
// );
// }
// common.expectsError(
// () => throwErr(),
// {
// code: 'ERR_ASSERTION',
// type: assert.AssertionError,
// message: 'The expression evaluated to a falsy value:\n\n ' +
// "assert(\n (Buffer.from('test') instanceof Error)\n )\n"
// }
// );
// common.expectsError(
// () => throwErr(),
// {
// code: 'ERR_ASSERTION',
// type: assert.AssertionError,
// message: 'The expression evaluated to a falsy value:\n\n ' +
// "assert(\n (Buffer.from('test') instanceof Error)\n )\n"
// }
// );
// fs.close = tmp;
// }

common.expectsError(
() => {
Expand Down

0 comments on commit 002f90a

Please sign in to comment.