Commit 8142691c 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/arguments-scope-expected.txt: Added.
        * fast/js/kde/arguments-scope.html: Added.
        * fast/js/kde/resources/arguments-scope.js: Added.
        * fast/js/kde/resources/scope.js:
        * fast/js/kde/scope-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5b4e8cab
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/arguments-scope-expected.txt: Added.
* fast/js/kde/arguments-scope.html: Added.
* fast/js/kde/resources/arguments-scope.js: Added.
* fast/js/kde/resources/scope.js:
* fast/js/kde/scope-expected.txt:
2007-11-11 Dan Bernstein <mitz@apple.com> 2007-11-11 Dan Bernstein <mitz@apple.com>
Reviewed by Adam Roben. Reviewed by Adam Roben.
......
KDE JS Test
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS test0
PASS test1
PASS test2
PASS test3
PASS test4.(1)
PASS test4.(2)
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/arguments-scope.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
// We can't use normal shouldBe here, since they'd eval in the wrong context...
function shouldBeOfType(msg, val, type) {
if (typeof(val) != type)
testFailed(msg + ": value has type " + typeof(val) + " , not:" + type);
else
testPassed(msg);
}
function test0() {
var arguments;
// var execution should not overwrite something that was
// in scope beforehand -- e.g. the arguments thing
shouldBeOfType("test0", arguments, 'object');
}
function test1() {
// No need to undef-initialize something in scope already!
shouldBeOfType("test1", arguments, 'object');
var arguments;
}
function test2(arguments) {
// Formals OTOH can overwrite the args object
shouldBeOfType("test2", arguments, 'number');
}
function test3() {
// Ditto for functions..
shouldBeOfType("test3", arguments, 'function');
function arguments() {}
}
function test4() {
// Here, the -declaration- part of the var below should have no
// effect..
shouldBeOfType('test4.(1)', arguments, 'object');
var arguments = 4;
// .. but the assignment shoud just happen
shouldBeOfType('test4.(2)', arguments, 'number');
}
test0();
test1();
test2(42);
test3();
test4();
var successfullyParsed = true;
...@@ -6,4 +6,31 @@ with (b) { ...@@ -6,4 +6,31 @@ with (b) {
} }
shouldBe("f(2)", "22"); shouldBe("f(2)", "22");
successfullyParsed = true
var OBJECT = new MyObject( "hello" );
function MyObject(value) {
this.value = value;
this.toString = new Function( "return this.value+''" );
return this;
}
shouldBe("OBJECT.toString()", "'hello'");
var s;
with (OBJECT) {
s = toString();
}
shouldBe("s", "'hello'");
// Make sure that for ... in reevaluates the scoping every time!
P = { foo : 1, bar : 2, baz : 3 }
function testForIn() {
for (g in P) {
eval("var g;") //Change the scope of g half-ways through the loop
}
}
testForIn();
shouldBe("g", "'foo'"); //Before the eval, g was in outer scope, but not after!
var successfullyParsed = true;
...@@ -4,6 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,6 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS f(2) is 22 PASS f(2) is 22
PASS OBJECT.toString() is 'hello'
PASS s is 'hello'
PASS g is 'foo'
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
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