Rubber-stamped by Oliver Hunt.
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2007 21:48:55 +0000 (21:48 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2007 21:48:55 +0000 (21:48 +0000)
        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: https://svn.webkit.org/repository/webkit/trunk@27722 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/js/kde/arguments-scope-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/kde/arguments-scope.html [new file with mode: 0644]
LayoutTests/fast/js/kde/resources/arguments-scope.js [new file with mode: 0644]
LayoutTests/fast/js/kde/resources/scope.js
LayoutTests/fast/js/kde/scope-expected.txt

index 6b356f8ccfd1467c9d90e50df8c63a155c1bee82..1a7c1ed894d9001a79713ce1b76a47906a4f768f 100644 (file)
@@ -1,3 +1,16 @@
+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>
 
         Reviewed by Adam Roben.
diff --git a/LayoutTests/fast/js/kde/arguments-scope-expected.txt b/LayoutTests/fast/js/kde/arguments-scope-expected.txt
new file mode 100644 (file)
index 0000000..07fea75
--- /dev/null
@@ -0,0 +1,15 @@
+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
+
diff --git a/LayoutTests/fast/js/kde/arguments-scope.html b/LayoutTests/fast/js/kde/arguments-scope.html
new file mode 100644 (file)
index 0000000..e88c417
--- /dev/null
@@ -0,0 +1,16 @@
+<!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>
diff --git a/LayoutTests/fast/js/kde/resources/arguments-scope.js b/LayoutTests/fast/js/kde/resources/arguments-scope.js
new file mode 100644 (file)
index 0000000..1506751
--- /dev/null
@@ -0,0 +1,51 @@
+// 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;
index 1aa3720f5775cdbbb0320305977dcc3908ad6a0f..acf315bd3a31ff30a21443964fb47b30d3ed734d 100644 (file)
@@ -6,4 +6,31 @@ with (b) {
 }
 
 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;
index 141c7bfda4d49e761ea2a9d0d4dd9dce749d2332..a33e874faa0e57d4502a4a104ad5f23f2345290a 100644 (file)
@@ -4,6 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS f(2) is 22
+PASS OBJECT.toString() is 'hello'
+PASS s is 'hello'
+PASS g is 'foo'
 PASS successfullyParsed is true
 
 TEST COMPLETE