[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: 2008-03-06 18:23:55
Message-ID: 1204827835.328448.2577.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 782984 by orlovich:
Add in testcase I came up w/while hacking on frostbyte (which fails a couple ATM)
M +66 -0 exception_propagation.js
M +10 -0 iteration.js
M +20 -0 operators.js
M +38 -0 scope.js
A sequencing.js
--- trunk/tests/khtmltests/regression/tests/js/exception_propagation.js #782983:782984
@@ -379,6 +379,9 @@
// ---------------------------------
// ### mozilla gives a syntax error on for (throwex() in forin_test_obj)... should we?
+// --- per spec, no, but we do in KDE4, so I commented this out for now. -- Maks
+
+/*
var forin_test_obj = new Object();
forin_test_obj.a = 1;
forin_test_obj.b = 2;
@@ -397,6 +400,8 @@
catch (e) {
}
shouldBe("forin_count","4");
+*/
+testFailed("Parsing of a CallExpression in for .. in");
// ---------------------------------
var set_inside_with_throw = 4;
@@ -421,3 +426,64 @@
}
shouldBe("set_inside_with_cantconverttoobject","4");
// ### test case, sw
+
+
+// ---------------------------------
+// Test to make sure finally propagates exceptions
+
+finallyRan = false;
+function testFinally() {
+ try {
+ throw 42;
+ } finally {
+ finallyRan = true;
+ }
+}
+
+var finallyPropagated = null;
+try {
+ testFinally();
+} catch (e) {
+ finallyPropagated = e;
+}
+
+shouldBe('finallyRan', 'true');
+shouldBe('finallyPropagated', '42');
+
+// A messier one, throwing things all over the place
+out = "";
+try {
+ try {
+ throw "a";
+ } catch(e) {
+ out += "<catch:" + e + ">";
+ throw "b";
+ } finally {
+ out += "<finally>";
+ throw("c");
+ }
+} catch (e) {
+ out += "<catch:" + e + ">";
+}
+
+shouldBe('out', '"<catch:a><finally><catch:c>"');
+
+// Basically the same thing, only not throwing a new one from finally
+out = "";
+try {
+ try {
+ throw "a";
+ } catch(e) {
+ out += "<catch:" + e + ">";
+ throw "b";
+ } finally {
+ out += "<finally>";
+ }
+} catch (e) {
+ out += "<catch:" + e + ">";
+}
+
+shouldBe('out', '"<catch:a><finally><catch:b>"');
+
+
+debug("Done.");
--- trunk/tests/khtmltests/regression/tests/js/iteration.js #782983:782984
@@ -116,4 +116,14 @@
shouldBe('iters', '10');
+// Regression test, bug during FB development.
+var o = {a: 0, b: 1}
+for (p in o) {
+ if (p == "b")
+ break;
+ continue;
+}
+testPassed("Didn't crash on continue in for .. in");
+
+debug("Done.");
--- trunk/tests/khtmltests/regression/tests/js/operators.js #782983:782984
@@ -243,3 +243,23 @@
shouldBe("(new Boolean()) instanceof Boolean", "true");
shouldBe("(new Boolean()) instanceof Number", "false");
+// Regression test for a ?: bug that showed up during FB work
+function testCond() {
+ // Need to be in function for var opt
+ var i = 42;
+ var j = (i != 42) ? i : 0;
+
+ if (i == 42)
+ testPassed("Test for ?: not messing up variable...");
+ else
+ testFailed("Test for ?: not messing up variable...");
+}
+
+testCond();
+
+// Parens in some references..
+shouldBe("var x = 0; ++(x); x", "1");
+shouldBe("var x = 0; (x)++; x", "1");
+
+
+debug("Done.");
--- trunk/tests/khtmltests/regression/tests/js/scope.js #782983:782984
@@ -32,3 +32,41 @@
testForIn();
shouldBe("g", "'foo'"); //Before the eval, g was in outer scope, but not after!
+
+// Check to make sure we cleanup the scope stack right
+o = { x : 4 }
+p = {};
+
+x = 42;
+
+label:with (o) {
+ break label;
+}
+
+with(p) { // We need 'with' here to prevent bypassing of the scope stack by the optimizer
+ y = x;
+}
+
+shouldBe('y', '42');
+
+// And a nastier one, also with a catch scope
+o = { x : 4 }
+p = {};
+
+x = 42;
+
+label:try {
+ throw "a";
+} catch (x) {
+ with (o) {
+ break label;
+ }
+}
+
+with(p) { // We need 'with' here to prevent bypassing of the scope stack by the optimizer
+ y = x;
+}
+
+shouldBe('y', '42');
+
+debug("Done.");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic