0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/test/parallel/test-eval-strict-referenceerror.js
Ujjwal Sharma 580ad0157a
test: name test files appropriately
Rename the tests appropriately alongside mentioning the subsystem.
Also, make a few basic changes to make sure the test conforms
to the standard test structure.

This renames:
- test-regress-GH-1531
- test-regress-GH-2245
- test-regress-GH-3238
- test-regress-GH-3542
- test-regress-GH-3739
- test-regress-GH-4256

PR-URL: https://github.com/nodejs/node/pull/19212
Refs: https://github.com/nodejs/node/issues/19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-11 04:17:42 +01:00

28 lines
623 B
JavaScript

/* eslint-disable strict */
require('../common');
// In Node.js 0.10, a bug existed that caused strict functions to not capture
// their environment when evaluated. When run in 0.10 `test()` fails with a
// `ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details.
const assert = require('assert');
function test() {
const code = [
'var foo = {m: 1};',
'',
'function bar() {',
'\'use strict\';',
'return foo; // foo isn\'t captured in 0.10',
'};'
].join('\n');
eval(code);
return bar(); // eslint-disable-line no-undef
}
assert.deepStrictEqual(test(), { m: 1 });