mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
common.js needs to be loaded in all tests so that there is checking for variable leaks and possibly other things. However, it does not need to be assigned to a variable if nothing in common.js is referred to elsewhere in the test. PR-URL: https://github.com/nodejs/node/pull/4408 Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
972 B
JavaScript
37 lines
972 B
JavaScript
// Flags: --expose_internals
|
|
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const internalUtil = require('internal/util');
|
|
|
|
assert.doesNotThrow(function() {
|
|
internalUtil.decorateErrorStack();
|
|
internalUtil.decorateErrorStack(null);
|
|
internalUtil.decorateErrorStack(1);
|
|
internalUtil.decorateErrorStack(true);
|
|
});
|
|
|
|
// Verify that a stack property is not added to non-Errors
|
|
const obj = {};
|
|
internalUtil.decorateErrorStack(obj);
|
|
assert.strictEqual(obj.stack, undefined);
|
|
|
|
// Verify that the stack is decorated when possible
|
|
let err;
|
|
|
|
try {
|
|
require('../fixtures/syntax/bad_syntax');
|
|
} catch (e) {
|
|
err = e;
|
|
assert(!/var foo bar;/.test(err.stack));
|
|
internalUtil.decorateErrorStack(err);
|
|
}
|
|
|
|
assert(/var foo bar;/.test(err.stack));
|
|
|
|
// Verify that the stack is unchanged when there is no arrow message
|
|
err = new Error('foo');
|
|
const originalStack = err.stack;
|
|
internalUtil.decorateErrorStack(err);
|
|
assert.strictEqual(originalStack, err.stack);
|