Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cceae5a

Browse filesBrowse files
kthelgasonrvagg
authored andcommitted
test: eval a strict function
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 1b7b1ed commit cceae5a
Copy full SHA for cceae5a

File tree

Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-0
lines changed
Open diff view settings
Collapse file
+28Lines changed: 28 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.