summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorKári Tristan Helgason <kthelgason@gmail.com>2016-02-15 22:55:35 +0000
committerJames M Snell <jasnell@gmail.com>2016-03-14 08:20:47 -0700
commit25eedf02a85bf3cac25f8f9b2c38d91969f52fcd (patch)
tree74c2b863e9235fd11be9c0cabf453110b15e4404 /test/parallel
parent995a33b5f6f6964152fb096be0f9982ca54a67db (diff)
downloadnode-new-25eedf02a85bf3cac25f8f9b2c38d91969f52fcd.tar.gz
test: eval a strict function
PR-URL: https://github.com/nodejs/node/pull/5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-regress-GH-2245.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-regress-GH-2245.js b/test/parallel/test-regress-GH-2245.js
new file mode 100644
index 0000000000..a7f54caa5f
--- /dev/null
+++ b/test/parallel/test-regress-GH-2245.js
@@ -0,0 +1,28 @@
+/* eslint-disable strict */
+require('../common');
+var assert = require('assert');
+
+/*
+in node 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.
+*/
+
+function test() {
+
+ var code = [
+ 'var foo = {m: 1};',
+ '',
+ 'function bar() {',
+ '\'use strict\';',
+ 'return foo; // foo isn\'t captured in 0.10',
+ '};'
+ ].join('\n');
+
+ eval(code);
+
+ return bar();
+
+}
+
+assert.deepEqual(test(), {m: 1});