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

Unified Diff: test/mjsunit/harmony/completion.js

Issue 1361403003: Implement ES6 completion semantics (--harmony-completion). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« src/rewriter.cc ('K') | « src/rewriter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/completion.js
diff --git a/test/mjsunit/harmony/completion.js b/test/mjsunit/harmony/completion.js
new file mode 100644
index 0000000000000000000000000000000000000000..c7d179148f404ae27d7d1daa4c4fb845f60a50eb
--- /dev/null
+++ b/test/mjsunit/harmony/completion.js
@@ -0,0 +1,56 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-completion
+
+
+function assertUndef(x) {
+ assertEquals(undefined, x);
+}
+
+
+// IfStatement [13.6.7]
+assertUndef(eval('42; if (true) ; else 0;')); // ES5: 42
+assertUndef(eval('42; if (true) ;')); // ES5: 42
+assertUndef(eval('42; if (false) 0;')); // ES5: 42
+
+
+// IterationStatement [13.7] (a few of them)
+assertUndef(eval('42; do ; while (false);')); // ES5: 42
+assertUndef(eval('42; var x = 1; do ; while (x--);')); // ES5: 42
+assertUndef(eval('42; while (false) 0;')); // ES5: 42
+assertUndef(eval('42; while (true) break;')); // ES5: 42
+assertUndef(eval('42; var x = 1; while (x--) ;')); // ES5: 42
+assertUndef(eval('42; for (; false; ) 0;')); // ES5: 42
+assertUndef(eval('42; for (var x = 1; x; x--) ;')); // ES5: 42
+
+
+// WithStatement [13.11.7]
+assertUndef(eval('42; with ({}) ;')); // ES5: 42
+
+
+// SwitchStatement [13.12.11]
+assertUndef(eval('42; switch (0) {};')); // ES5: 42
+assertUndef(eval('42; switch (0) { case 1: 1; };')); // ES5: 42
+assertUndef(eval('42; switch (0) { case 0: ; };')); // ES5: 42
+assertUndef(eval('42; switch (0) { default: ; };')); // ES5: 42
+assertUndef(eval('42; switch (0) { case 0: break; }')); // ES5: 42
+assertEquals(0, eval('42; switch (0) { case 0: 0; }'));
+assertEquals(0, eval('42; switch (0) { case 0: 0; break; }'));
+
+
+// TryStatement [13.15.8]
+assertUndef(eval('42; try { } catch(e) { };')); // ES5: 42
+assertUndef(eval('42; try { } catch(e) { 0; };')); // ES5: 42
+assertUndef(eval('42; try { throw Error } catch(e) { };')); // ES5: 42
+assertUndef(eval('42; try { throw Error } catch(e) { } finally { };')); // ES5: 42
+
+
+// Some combinations
+assertUndef(eval('42; switch (0) { case 0: if (true) break; }')); // ES5: 42
+assertUndef(eval('42; switch (0) { case 0: 0; if (true) ; }')); // ES5: 0
+assertUndef(eval('42; switch (0) { case 0: 0; try { break } catch(e) { }; }')); // ES5: 0
+
+// The following is not what ES6 says, but see ES bug 4540.
+assertUndef(eval('42; switch (0) { case 0: 0; if (true) break; }')); // ES5: 0
« src/rewriter.cc ('K') | « src/rewriter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698