Commit d9fffcca authored by ggaren@apple.com's avatar ggaren@apple.com

Rubber-stamped by Oliver Hunt.

        
        Landing a few layout tests from http://bugs.webkit.org/show_bug.cgi?id=14868
        Import variable lookup optimizations from KJS

        * fast/js/kde/lval-exceptions-expected.txt: Added.
        * fast/js/kde/lval-exceptions.html: Added.
        * fast/js/kde/operators-expected.txt:
        * fast/js/kde/resources/lval-exceptions.js: Added.
        * fast/js/kde/resources/operators.js:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27725 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c7c3a535
2007-11-12 Geoffrey Garen <ggaren@apple.com>
Rubber-stamped by Oliver Hunt.
Landing a few layout tests from http://bugs.webkit.org/show_bug.cgi?id=14868
Import variable lookup optimizations from KJS
* fast/js/kde/lval-exceptions-expected.txt: Added.
* fast/js/kde/lval-exceptions.html: Added.
* fast/js/kde/operators-expected.txt:
* fast/js/kde/resources/lval-exceptions.js: Added.
* fast/js/kde/resources/operators.js:
2007-11-12 Geoffrey Garen <ggaren@apple.com>
Rubber-stamped by Oliver Hunt.
......
KDE JS Test
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS function ()
{
a = x;
} threw exception ReferenceError: Can't find variable: x.
PASS function ()
{
x += "foo";
} threw exception ReferenceError: Can't find variable: x.
PASS function ()
{
b = a.x;
} did not throw an exception
PASS function ()
{
b = a["x"];
} did not throw an exception
PASS function ()
{
a["x"] += "baz";
} did not throw an exception
PASS a['x'] is "undefinedbaz"
PASS function ()
{
b = a.y;
} did not throw an exception
PASS function ()
{
a.y += "glarch";
} did not throw an exception
PASS a['y'] is "undefinedglarch"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../resources/js-test-style.css">
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("KDE JS Test");
</script>
<script src="resources/lval-exceptions.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
......@@ -11,6 +11,10 @@ PASS !!1 is true
PASS !0 is true
PASS !!'a' is true
PASS !'' is true
PASS +9 is 9
PASS var i = 10; +i is 10
PASS -11 is -11
PASS var i = 12; -i is -12
PASS var i = 0; ++i; is 1
PASS var i = 0; ++i; i is 1
PASS var i = 0; i++; is 0
......@@ -25,6 +29,8 @@ PASS var i = true; i-- is 1
PASS var i = true; i--; i is 0
PASS ~0 is -1
PASS ~1 is -2
PASS ~NaN is -1
PASS ~Infinity is -1
PASS ~Math.pow(2, 33) is -1
PASS ~(Math.pow(2, 32) + Math.pow(2, 31) + 2) is 2147483645
PASS ~null is -1
......@@ -40,6 +46,21 @@ PASS -8 >> 24 is -1
PASS 8 >>> 2 is 2
PASS -8 >>> 24 is 255
PASS (-2200000000 >> 1) << 1 is 2094967296
PASS Infinity >> 1 is 0
PASS Infinity << 1 is 0
PASS Infinity >>> 1 is 0
PASS NaN >> 1 is 0
PASS NaN << 1 is 0
PASS NaN >>> 1 is 0
PASS 8.1 >> 1 is 4
PASS 8.1 << 1 is 16
PASS 8.1 >>> 1 is 4
PASS 8.9 >> 1 is 4
PASS 8.9 << 1 is 16
PASS 8.9 >>> 1 is 4
PASS Math.pow(2, 32) >> 1 is 0
PASS Math.pow(2, 32) << 1 is 0
PASS Math.pow(2, 32) >>> 1 is 0
PASS 1+2 is 3
PASS 'a'+'b' is 'ab'
PASS 'a'+2 is 'a2'
......@@ -152,6 +173,8 @@ PASS NaN === NaN is false
PASS 0.0 === 0 is true
PASS 'abc' === 'abc' is true
PASS 'a' === 'x' is false
PASS 1 === '1' is false
PASS '1' === 1 is false
PASS true === true is true
PASS false === false is true
PASS true === false is false
......
// Tests for raising --- and non-raising exceptions on access to reference to undefined things...
// Locals should throw on access if undefined..
fnShouldThrow(function() { a = x; }, ReferenceError);
// Read-modify-write versions of assignment should throw as well
fnShouldThrow(function() { x += "foo"; }, ReferenceError);
// Other reference types should just return undefined...
a = new Object();
fnShouldNotThrow(function() { b = a.x; });
fnShouldNotThrow(function() { b = a['x']; });
fnShouldNotThrow(function() { a['x'] += 'baz'; });
shouldBe("a['x']", '"undefinedbaz"');
fnShouldNotThrow(function() { b = a.y; });
fnShouldNotThrow(function() { a.y += 'glarch'; });
shouldBe("a['y']", '"undefinedglarch"');
// Helpers!
function fnShouldThrow(f, exType)
{
var exception;
var _av;
try {
_av = f();
} catch (e) {
exception = e;
}
if (exception) {
if (typeof exType == "undefined" || exception instanceof exType)
testPassed(f + " threw exception " + exception + ".");
else
testFailed(f + " should throw exception " + exType + ". Threw exception " + exception + ".");
} else if (typeof _av == "undefined")
testFailed(f + " should throw exception " + exType + ". Was undefined.");
else
testFailed(f + " should throw exception " + exType + ". Was " + _av + ".");
}
function fnShouldNotThrow(f)
{
try {
f();
testPassed(f + " did not throw an exception");
} catch (e) {
testFailed(f + " threw an exception " + e + " when no exception expected");
}
}
var successfullyParsed = true;
......@@ -8,6 +8,14 @@ shouldBeTrue("!0");
shouldBeTrue("!!'a'");
shouldBeTrue("!''");
// unary plus
shouldBe("+9", "9");
shouldBe("var i = 10; +i", "10");
// negation
shouldBe("-11", "-11");
shouldBe("var i = 12; -i", "-12");
// increment
shouldBe("var i = 0; ++i;", "1");
shouldBe("var i = 0; ++i; i", "1");
......@@ -27,6 +35,8 @@ shouldBe("var i = true; i--; i", "0");
// bitwise operators
shouldBe("~0", "-1");
shouldBe("~1", "-2");
shouldBe("~NaN", "-1");
shouldBe("~Infinity", "-1");
shouldBe("~Math.pow(2, 33)", "-1"); // 32 bit overflow
shouldBe("~(Math.pow(2, 32) + Math.pow(2, 31) + 2)",
"2147483645"); // a signedness issue
......@@ -44,6 +54,21 @@ shouldBe("-8 >> 24", "-1");
shouldBe("8 >>> 2", "2");
shouldBe("-8 >>> 24", "255");
shouldBe("(-2200000000 >> 1) << 1", "2094967296");
shouldBe("Infinity >> 1", "0");
shouldBe("Infinity << 1", "0");
shouldBe("Infinity >>> 1", "0");
shouldBe("NaN >> 1", "0");
shouldBe("NaN << 1", "0");
shouldBe("NaN >>> 1", "0");
shouldBe("8.1 >> 1", "4");
shouldBe("8.1 << 1", "16");
shouldBe("8.1 >>> 1", "4");
shouldBe("8.9 >> 1", "4");
shouldBe("8.9 << 1", "16");
shouldBe("8.9 >>> 1", "4");
shouldBe("Math.pow(2, 32) >> 1", "0");
shouldBe("Math.pow(2, 32) << 1", "0");
shouldBe("Math.pow(2, 32) >>> 1", "0");
// addition
shouldBe("1+2", "3");
......@@ -180,6 +205,8 @@ shouldBe("NaN === NaN", "false");
shouldBe("0.0 === 0", "true");
shouldBe("'abc' === 'abc'", "true");
shouldBe("'a' === 'x'", "false");
shouldBe("1 === '1'", "false");
shouldBe("'1' === 1", "false");
shouldBe("true === true", "true");
shouldBe("false === false", "true");
shouldBe("true === false", "false");
......@@ -216,4 +243,4 @@ shouldBeTrue("'a' in { a:1, b:2 }");
shouldBe("(new Boolean()) instanceof Boolean", "true");
shouldBe("(new Boolean()) instanceof Number", "false");
successfullyParsed = true
var successfullyParsed = true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment