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

Unified Diff: test/mjsunit/harmony/do-expressions-control.js

Issue 1724753002: [fullcodegen] Implement control flow across do-expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/flag-definitions.h ('K') | « src/full-codegen/ia32/full-codegen-ia32.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/do-expressions-control.js
diff --git a/test/mjsunit/harmony/do-expressions-control.js b/test/mjsunit/harmony/do-expressions-control.js
new file mode 100644
index 0000000000000000000000000000000000000000..fbc9c2dac4855ac74f5d433112fab78ab283af7d
--- /dev/null
+++ b/test/mjsunit/harmony/do-expressions-control.js
@@ -0,0 +1,53 @@
+// Copyright 2016 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: --allow-natives-syntax --harmony-do-expressions
+
+(function TestDoForInDoBreak() {
rossberg 2016/02/23 14:38:33 Might be worth also having tests with labeled brea
Michael Starzinger 2016/02/23 15:52:40 Done.
rossberg 2016/02/23 16:04:32 Awesome, thanks!
+ function f(o, i) {
+ var a = "result@" + do {
+ var r = "(";
+ for (var x in o) {
+ var b = "end@" + do {
+ if (x == i) { break } else { r += o[x]; x }
+ }
+ }
+ r + ")";
+ }
+ return a + "," + b;
+ }
+ assertEquals("result@(3),end@0", f([3], 2));
+ assertEquals("result@(35),end@1", f([3,5], 2));
+ assertEquals("result@(35),end@1", f([3,5,7], 2));
+ assertEquals("result@(35),end@1", f([3,5,7,9], 2));
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals("result@(3),end@0", f([3], 2));
+ assertEquals("result@(35),end@1", f([3,5], 2));
+ assertEquals("result@(35),end@1", f([3,5,7], 2));
+ assertEquals("result@(35),end@1", f([3,5,7,9], 2));
+})();
+
+(function TestDoForInDoContinue() {
+ function f(o, i) {
+ var a = "result@" + do {
+ var r = "("
+ for (var x in o) {
+ var b = "end@" + do {
+ if (x == i) { continue } else { r += o[x]; x }
+ }
+ }
+ r + ")"
+ }
+ return a + "," + b
+ }
+ assertEquals("result@(3),end@0", f([3], 2));
+ assertEquals("result@(35),end@1", f([3,5], 2));
+ assertEquals("result@(35),end@1", f([3,5,7], 2));
+ assertEquals("result@(359),end@3", f([3,5,7,9], 2));
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals("result@(3),end@0", f([3], 2));
+ assertEquals("result@(35),end@1", f([3,5], 2));
+ assertEquals("result@(35),end@1", f([3,5,7], 2));
+ assertEquals("result@(359),end@3", f([3,5,7,9], 2));
+})();
« src/flag-definitions.h ('K') | « src/full-codegen/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698