From ee120b008f747eebb44c2b85c53eec0305a7cd4f Mon Sep 17 00:00:00 2001 From: "armin@diedering.de" Date: Sun, 1 Jan 2012 14:36:21 +0000 Subject: [PATCH] 42tiny-js: - added Lexer can now detect regular expression literals but using of regular expression are currently unsupported - added function closure test "tests/42tests/test002.js" --- tests/42tests/test002.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/42tests/test002.js diff --git a/tests/42tests/test002.js b/tests/42tests/test002.js new file mode 100644 index 0000000..ad41262 --- /dev/null +++ b/tests/42tests/test002.js @@ -0,0 +1,12 @@ +// function-closure + +var a = 40; // a global var + +function closure() { + var a = 39; // a local var; + return function() { return a; }; +} + +var b = closure(); // the local var a is now hidden + +result = b()+3 == 42 && a+2 == 42;