- test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5210
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2006 01:43:42 +0000 (01:43 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Feb 2006 01:43:42 +0000 (01:43 +0000)
          REGRESSION: for/in loop with var changes global variable instead of making local

        * fast/js/for-in-var-scope.html: Added.
        * fast/js/resources/for-in-var-scope.js: Added.
        * fast/js/for-in-var-scope-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12565 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 506d5897fd4f2797c55c03d127412b9bb17a72b3..87e3165ec4e0f531eb96e3574bc7d042b56a6efd 100644 (file)
@@ -1,3 +1,12 @@
+2006-02-03  Darin Adler  <darin@apple.com>
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5210
+          REGRESSION: for/in loop with var changes global variable instead of making local
+
+        * fast/js/for-in-var-scope.html: Added.
+        * fast/js/resources/for-in-var-scope.js: Added.
+        * fast/js/for-in-var-scope-expected.txt: Added.
+
 2006-02-03  Darin Adler  <darin@apple.com>
 
         - updated test result due to revised fix for <ol> number
diff --git a/LayoutTests/fast/js/for-in-var-scope-expected.txt b/LayoutTests/fast/js/for-in-var-scope-expected.txt
new file mode 100644 (file)
index 0000000..7369ab7
--- /dev/null
@@ -0,0 +1,11 @@
+This tests that for/in statements properly scope a variable that's declared in one. In previous versions of JavaScriptCore there were two bugs that caused problems. First, the loop variable declaration would not be processed. Second, the code to set the loop variable would incorrectly walk the scope chain even after setting the loop variable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS i is 'start i'
+PASS j is 'propName'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/for-in-var-scope.html b/LayoutTests/fast/js/for-in-var-scope.html
new file mode 100644 (file)
index 0000000..c6c8ad8
--- /dev/null
@@ -0,0 +1,13 @@
+<!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 src="resources/for-in-var-scope.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/resources/for-in-var-scope.js b/LayoutTests/fast/js/resources/for-in-var-scope.js
new file mode 100644 (file)
index 0000000..72724ae
--- /dev/null
@@ -0,0 +1,21 @@
+description(
+"This tests that for/in statements properly scope a variable that's declared in one. "
++ "In previous versions of JavaScriptCore there were two bugs that caused problems. "
++ "First, the loop variable declaration would not be processed. "
++ "Second, the code to set the loop variable would incorrectly walk the scope chain even after setting the loop variable."
+);
+
+var i = "start i";
+var j = "start j";
+
+function func() {
+    var object = new Object;
+    object.propName = "propValue";
+    for (var i in object) { j = i; }
+}
+func();
+
+shouldBe("i", "'start i'");
+shouldBe("j", "'propName'");
+
+var successfullyParsed = true;