Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: test/mjsunit/harmony/block-scoping.js

Issue 7549008: Preliminary code for block scopes and block contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Next iteration Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/block-scoping.js
diff --git a/test/mjsunit/harmony/block-scoping.js b/test/mjsunit/harmony/block-scoping.js
new file mode 100644
index 0000000000000000000000000000000000000000..6247914ad5f483d285e1688ff243dd1a6f1b9dbe
--- /dev/null
+++ b/test/mjsunit/harmony/block-scoping.js
@@ -0,0 +1,30 @@
+// Flags: --allow-natives-syntax --harmony-block-scoping
Kevin Millikin (Chromium) 2011/08/10 11:19:27 The test file needs a copyright notice.
Steven 2011/08/10 12:21:00 Done.
+
+// Hoisting of var declarations.
+function f1() {
+ {
+ var x = 1;
+ var y;
+ }
+ assertEquals(1, x)
+ assertEquals(undefined, y)
+}
+f1();
+
+// Dynamic lookup through block scopes.
+function f2(one) {
+ var x = one + 1;
+ // TODO(keuchel): introduce let
+ // let y = one + 2;
+ if (one == 1) {
+ // Parameter
+ assertEquals(1, eval('one'));
+ // Function local var variable
+ assertEquals(2, eval('x'));
+ // Function local let variable
+ // TODO(keuchel): introduce let
+ // assertEquals(3, eval('y'));
+ }
+}
+f2();
+

Powered by Google App Engine
This is Rietveld 408576698