Skip to content

Commit 1235176

Browse files
kthelgasonevanlucas
authored andcommitted
test: eval a strict function
PR-URL: #5250 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent a6b5272 commit 1235176

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/parallel/test-regress-GH-2245.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable strict */
2+
require('../common');
3+
var assert = require('assert');
4+
5+
/*
6+
in node 0.10 a bug existed that caused strict functions to not capture
7+
their environment when evaluated. When run in 0.10 `test()` fails with a
8+
`ReferenceError`. See https://github.com/nodejs/node/issues/2245 for details.
9+
*/
10+
11+
function test() {
12+
13+
var code = [
14+
'var foo = {m: 1};',
15+
'',
16+
'function bar() {',
17+
'\'use strict\';',
18+
'return foo; // foo isn\'t captured in 0.10',
19+
'};'
20+
].join('\n');
21+
22+
eval(code);
23+
24+
return bar();
25+
26+
}
27+
28+
assert.deepEqual(test(), {m: 1});

0 commit comments

Comments
 (0)