[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    tests/khtmltests/regression/tests/js
From:       Maks Orlovich <maksim () kde ! org>
Date:       2007-06-11 22:08:42
Message-ID: 1181599722.712169.28523.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 674167 by orlovich:

Some testcases for label/control flow bugs we used to have, and some related 
symmetric testcases for stuff we always got right.


 M  +42 -0     iteration.js  


--- trunk/tests/khtmltests/regression/tests/js/iteration.js #674166:674167
@@ -75,3 +75,45 @@
 shouldBe("laterForBreak", "'zilch'");
 var forEnd = eval("for(var y = 0; y < 4; ++y) { 'quark' }");
 shouldBe("forEnd", "'quark'");
+
+// Various stuff for control flow and error handling of break/continue
+var iters;
+
+// Test whether we handle multiple labels on the same statement right
+// Note: this is in a function since konq 3.x just breaks out of the whole thing.
+function testLabelNest() {
+  iters = 0;
+  foo: bar: while (true) {
+    ++iters;
+    if (iters < 10)
+      continue foo;
+    else
+      break;
+  }
+}
+
+testLabelNest();
+shouldBe('iters', '10');
+
+// Test to make sure doing continue outside a loop
+// throws properly. (3.x didn't), and so does a label-less
+// break outside of it.
+shouldThrow('foo: continue foo; ');
+shouldThrow('continue; ');
+shouldThrow('break;');
+
+// These ones should be fine OTOH
+shouldBeUndefined('foo: break foo; ');
+shouldBe('foo: { a = 1; break foo; a = 2; }', '1');
+
+// Make sure we don't break out too far.
+function testLocalBreak() {
+  l: break l;
+}
+
+for (iters = 0; iters < 10; ++iters)
+  testLocalBreak();
+
+shouldBe('iters', '10');
+
+
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic