<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181886] trunk/LayoutTests</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181886">181886</a></dd>
<dt>Author</dt> <dd>fpizlo@apple.com</dd>
<dt>Date</dt> <dd>2015-03-23 18:48:54 -0700 (Mon, 23 Mar 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move the bulk of the js/dom/const test into js/const, so that run-jsc-stress-tests runs it.
Rubber stamped by Andreas Kling and Michael Saboff.
* js/const-expected.txt: Copied from LayoutTests/js/dom/const-expected.txt.
* js/const.html: Copied from LayoutTests/js/dom/const.html.
* js/dom/const-expected.txt: Replaced.
* js/dom/const.html: Replaced.
* js/resources/const.js: Removed.
* js/script-tests/const.js: Copied from LayoutTests/js/resources/const.js.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsconstexpectedtxt">trunk/LayoutTests/js/const-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsconsthtml">trunk/LayoutTests/js/const.html</a></li>
<li><a href="#trunkLayoutTestsjsdomconstexpectedtxt">trunk/LayoutTests/js/dom/const-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomconsthtml">trunk/LayoutTests/js/dom/const.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsconstjs">trunk/LayoutTests/js/script-tests/const.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsdomconstexpectedtxt">trunk/LayoutTests/js/dom/const-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomconsthtml">trunk/LayoutTests/js/dom/const.html</a></li>
<li><a href="#trunkLayoutTestsjsresourcesconstjs">trunk/LayoutTests/js/resources/const.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181885 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-24 01:28:06 UTC (rev 181885)
+++ trunk/LayoutTests/ChangeLog        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-03-23 Filip Pizlo <fpizlo@apple.com>
+
+ Move the bulk of the js/dom/const test into js/const, so that run-jsc-stress-tests runs it.
+
+ Rubber stamped by Andreas Kling and Michael Saboff.
+
+ * js/const-expected.txt: Copied from LayoutTests/js/dom/const-expected.txt.
+ * js/const.html: Copied from LayoutTests/js/dom/const.html.
+ * js/dom/const-expected.txt: Replaced.
+ * js/dom/const.html: Replaced.
+ * js/resources/const.js: Removed.
+ * js/script-tests/const.js: Copied from LayoutTests/js/resources/const.js.
+
</ins><span class="cx"> 2015-03-23 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> [Content Filtering] Fix up a few mistakes in LayoutTests/contentfiltering/
</span></span></pre></div>
<a id="trunkLayoutTestsjsconstexpectedtxtfromrev181875trunkLayoutTestsjsdomconstexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/js/const-expected.txt (from rev 181875, trunk/LayoutTests/js/dom/const-expected.txt) (0 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/const-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/const-expected.txt        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+This test checks that const declarations in JavaScript work and are readonly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+FAIL const redef='a'; const redef='a'; should throw an exception. Was undefined.
+PASS x is "RIGHT"
+PASS y is "RIGHT"
+PASS a is 1
+PASS one is 1
+PASS a is 1
+PASS one is 1
+PASS a is 2
+PASS one is 1
+PASS a is 0
+PASS one is 1
+PASS a is 3
+PASS one is 1
+PASS a is 2
+PASS one is 1
+PASS function f() { const one = 1; one++; return one; } f(); is 1
+PASS function f() { const oneString = '1'; return oneString++; } f(); is 1
+PASS function f() { const one = 1; return one++; } f(); is 1
+PASS function f() { const one = 1; one--; return one; } f(); is 1
+PASS function f() { const oneString = '1'; return oneString--; } f(); is 1
+PASS function f() { const one = 1; return one--; } f(); is 1
+PASS function f() { const one = 1; ++one; return one; } f(); is 1
+PASS function f() { const one = 1; return ++one; } f(); is 2
+PASS function f() { const one = 1; --one; return one; } f(); is 1
+PASS function f() { const one = 1; return --one; } f(); is 0
+PASS function f() { const one = 1; one += 2; return one; } f(); is 1
+PASS function f() { const one = 1; return one += 2; } f(); is 3
+PASS function f() { const one = 1; one = 2; return one; } f(); is 1
+PASS function f() { const one = 1; return one = 2; } f(); is 2
+PASS one++ is 1
+PASS one is 1
+PASS one-- is 1
+PASS one is 1
+PASS ++one is 2
+PASS one is 1
+PASS --one is 0
+PASS one is 1
+PASS one += 1 is 2
+PASS one is 1
+PASS one = 2 is 2
+PASS one is 1
+PASS object.inWith1 is 'RIGHT'
+PASS inWith2 is 'RIGHT'
+PASS (function(){ one = 2; return one; })() is 1
+PASS f() is f
+PASS const a; is undefined
+PASS tryCatch1Result is 5
+PASS tryCatch2Result is 5
+PASS with1Result is 5
+PASS with2Result is 5
+PASS PASS: ++x should be 2 and is.
+PASS PASS: --x should be 0 and is.
+PASS PASS: x should be 1 and is.
+PASS PASS: x++ should be 1 and is.
+PASS PASS: x should be 1 and is.
+PASS PASS: ++x should be 2 and is.
+PASS PASS: x should be 1 and is.
+PASS PASS: x++ should be 1 and is.
+PASS PASS: x should be 1 and is.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsconsthtmlfromrev181875trunkLayoutTestsjsdomconsthtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/js/const.html (from rev 181875, trunk/LayoutTests/js/dom/const.html) (0 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/const.html         (rev 0)
+++ trunk/LayoutTests/js/const.html        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/const.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsdomconstexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/js/dom/const-expected.txt (181885 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/const-expected.txt        2015-03-24 01:28:06 UTC (rev 181885)
+++ trunk/LayoutTests/js/dom/const-expected.txt        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -1,70 +0,0 @@
</span><del>-This test checks that const declarations in JavaScript work and are readonly.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-FAIL const redef='a'; const redef='a'; should throw an exception. Was undefined.
-PASS x is "RIGHT"
-PASS y is "RIGHT"
-PASS a is 1
-PASS one is 1
-PASS a is 1
-PASS one is 1
-PASS a is 2
-PASS one is 1
-PASS a is 0
-PASS one is 1
-PASS a is 3
-PASS one is 1
-PASS a is 2
-PASS one is 1
-PASS function f() { const one = 1; one++; return one; } f(); is 1
-PASS function f() { const oneString = '1'; return oneString++; } f(); is 1
-PASS function f() { const one = 1; return one++; } f(); is 1
-PASS function f() { const one = 1; one--; return one; } f(); is 1
-PASS function f() { const oneString = '1'; return oneString--; } f(); is 1
-PASS function f() { const one = 1; return one--; } f(); is 1
-PASS function f() { const one = 1; ++one; return one; } f(); is 1
-PASS function f() { const one = 1; return ++one; } f(); is 2
-PASS function f() { const one = 1; --one; return one; } f(); is 1
-PASS function f() { const one = 1; return --one; } f(); is 0
-PASS function f() { const one = 1; one += 2; return one; } f(); is 1
-PASS function f() { const one = 1; return one += 2; } f(); is 3
-PASS function f() { const one = 1; one = 2; return one; } f(); is 1
-PASS function f() { const one = 1; return one = 2; } f(); is 2
-PASS one++ is 1
-PASS one is 1
-PASS one-- is 1
-PASS one is 1
-PASS ++one is 2
-PASS one is 1
-PASS --one is 0
-PASS one is 1
-PASS one += 1 is 2
-PASS one is 1
-PASS one = 2 is 2
-PASS one is 1
-PASS object.inWith1 is 'RIGHT'
-PASS inWith2 is 'RIGHT'
-PASS (function(){ one = 2; return one; })() is 1
-PASS f() is f
-PASS const a; is undefined
-PASS bodyId is document.getElementById('bodyId')
-PASS ranConstInitialiser is true
-PASS tryCatch1Result is 5
-PASS tryCatch2Result is 5
-PASS with1Result is 5
-PASS with2Result is 5
-PASS PASS: ++x should be 2 and is.
-PASS PASS: --x should be 0 and is.
-PASS PASS: x should be 1 and is.
-PASS PASS: x++ should be 1 and is.
-PASS PASS: x should be 1 and is.
-PASS PASS: ++x should be 2 and is.
-PASS PASS: x should be 1 and is.
-PASS PASS: x++ should be 1 and is.
-PASS PASS: x should be 1 and is.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestsjsdomconstexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/dom/const-expected.txt (0 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/const-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/dom/const-expected.txt        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+This test checks that const declarations in JavaScript work and are readonly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS bodyId is document.getElementById('bodyId')
+PASS ranConstInitialiser is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsdomconsthtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/js/dom/const.html (181885 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/const.html        2015-03-24 01:28:06 UTC (rev 181885)
+++ trunk/LayoutTests/js/dom/const.html        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -1,10 +0,0 @@
</span><del>-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
-<body id="bodyId">
-<script src="../resources/const.js"></script>
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestsjsdomconsthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/dom/const.html (0 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/const.html         (rev 0)
+++ trunk/LayoutTests/js/dom/const.html        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Const test</title>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="bodyId">
+<script>
+description(
+"This test checks that const declarations in JavaScript work and are readonly."
+);
+
+// Make sure we don't override properties placed on the global object
+var ranConstInitialiser = false;
+const bodyId = (ranConstInitialiser = true, "Const initialiser overwrote existing property");
+shouldBe("bodyId", "document.getElementById('bodyId')");
+shouldBeTrue("ranConstInitialiser");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsresourcesconstjs"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/js/resources/const.js (181885 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/resources/const.js        2015-03-24 01:28:06 UTC (rev 181885)
+++ trunk/LayoutTests/js/resources/const.js        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -1,190 +0,0 @@
</span><del>-description(
-"This test checks that const declarations in JavaScript work and are readonly."
-);
-
-
-shouldThrow("const redef='a'; const redef='a';");
-
-const x = "RIGHT";
-x = "WRONG";
-shouldBe("x", '"RIGHT"');
-
-const z = "RIGHT", y = "RIGHT";
-y = "WRONG";
-shouldBe("y", '"RIGHT"');
-
-const one = 1;
-
-var a;
-
-// PostIncResolveNode
-a = one++;
-shouldBe("a", "1");
-shouldBe("one", "1");
-
-// PostDecResolveNode
-a = one--;
-shouldBe("a", "1");
-shouldBe("one", "1");
-
-// PreIncResolveNode
-a = ++one;
-shouldBe("a", "2");
-shouldBe("one", "1");
-
-// PreDecResolveNode
-a = --one;
-shouldBe("a", "0");
-shouldBe("one", "1");
-
-// ReadModifyConstNode
-a = one += 2;
-shouldBe("a", "3");
-shouldBe("one", "1");
-
-// AssignConstNode
-a = one = 2;
-shouldBe("a", "2");
-shouldBe("one", "1");
-
-// PostIncResolveNode
-shouldBe("function f() { const one = 1; one++; return one; } f();", "1");
-shouldBe("function f() { const oneString = '1'; return oneString++; } f();", "1");
-shouldBe("function f() { const one = 1; return one++; } f();", "1");
-
-// PostDecResolveNode
-shouldBe("function f() { const one = 1; one--; return one; } f();", "1");
-shouldBe("function f() { const oneString = '1'; return oneString--; } f();", "1");
-shouldBe("function f() { const one = 1; return one--; } f();", "1");
-
-// PreIncResolveNode
-shouldBe("function f() { const one = 1; ++one; return one; } f();", "1");
-shouldBe("function f() { const one = 1; return ++one; } f();", "2");
-
-// PreDecResolveNode
-shouldBe("function f() { const one = 1; --one; return one; } f();", "1");
-shouldBe("function f() { const one = 1; return --one; } f();", "0");
-
-// ReadModifyConstNode
-shouldBe("function f() { const one = 1; one += 2; return one; } f();", "1");
-shouldBe("function f() { const one = 1; return one += 2; } f();", "3");
-
-// AssignConstNode
-shouldBe("function f() { const one = 1; one = 2; return one; } f();", "1");
-shouldBe("function f() { const one = 1; return one = 2; } f();", "2");
-
-// PostIncResolveNode
-shouldBe("one++", "1");
-shouldBe("one", "1");
-
-// PostDecResolveNode
-shouldBe("one--", "1");
-shouldBe("one", "1");
-
-// PreIncResolveNode
-shouldBe("++one", "2");
-shouldBe("one", "1");
-
-// PreDecResolveNode
-shouldBe("--one", "0");
-shouldBe("one", "1");
-
-// ReadModifyConstNode
-shouldBe("one += 1", "2");
-shouldBe("one", "1");
-
-// AssignConstNode
-shouldBe("one = 2", "2");
-shouldBe("one", "1");
-
-var object = { inWith1: "RIGHT", inWith2: ""}
-with (object) {
- const inWith1 = "WRONG";
- const inWith2 = "RIGHT";
- inWith2 = "WRONG";
-}
-shouldBe("object.inWith1", "'RIGHT'");
-shouldBe("inWith2", "'RIGHT'");
-
-shouldBe("(function(){ one = 2; return one; })()", "1")
-var f = function g() { g="FAIL"; return g; };
-shouldBe("f()", "f");
-
-shouldBe("const a;", "undefined");
-
-// Make sure we don't override properties placed on the global object
-var ranConstInitialiser = false;
-const bodyId = (ranConstInitialiser = true, "Const initialiser overwrote existing property");
-shouldBe("bodyId", "document.getElementById('bodyId')");
-shouldBeTrue("ranConstInitialiser");
-
-// Make sure that dynamic scopes (catch, with) don't break const declarations
-function tryCatch1() {
- var bar;
- eval("try {\
- stuff();\
- } catch (e) {\
- const bar = 5;\
- }");
- return bar;
-}
-
-function tryCatch2() {
- var bar;
- try {
- stuff();
- } catch (e) {
- const bar = 5;
- }
- return bar;
-}
-
-tryCatch1Result = tryCatch1();
-shouldBe("tryCatch1Result", "5");
-tryCatch2Result = tryCatch2();
-shouldBe("tryCatch2Result", "5");
-
-function with1() {
- var bar;
- eval("with({foo:42}) const bar = 5;");
- return bar;
-}
-
-function with2() {
- var bar;
- with({foo:42}) const bar = 5;
- return bar;
-}
-
-with1Result = with1();
-shouldBe("with1Result", "5");
-with2Result = with2();
-shouldBe("with2Result", "5");
-
-(function () {
- function shouldBe(aDescription, a, b)
- {
- if (a === b) {
- testPassed("PASS: " + aDescription + " should be " + b + " and is.");
- return;
- }
-
- testFailed("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
- }
-
- (function() {
- const x = "1";
- shouldBe("++x", ++x, 2);
- shouldBe("--x", --x, 0);
- shouldBe("x", x, "1");
- shouldBe("x++", x++, 1);
- shouldBe("x", x, "1");
- })();
- (function() {
- const x = 1;
- shouldBe("++x", ++x, 2);
- shouldBe("x", x, 1);
- shouldBe("x++", x++, 1);
- shouldBe("x", x, 1);
- })();
-})();
</del></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsconstjsfromrev181875trunkLayoutTestsjsresourcesconstjs"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/js/script-tests/const.js (from rev 181875, trunk/LayoutTests/js/resources/const.js) (0 => 181886)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/const.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/const.js        2015-03-24 01:48:54 UTC (rev 181886)
</span><span class="lines">@@ -0,0 +1,184 @@
</span><ins>+description(
+"This test checks that const declarations in JavaScript work and are readonly."
+);
+
+
+shouldThrow("const redef='a'; const redef='a';");
+
+const x = "RIGHT";
+x = "WRONG";
+shouldBe("x", '"RIGHT"');
+
+const z = "RIGHT", y = "RIGHT";
+y = "WRONG";
+shouldBe("y", '"RIGHT"');
+
+const one = 1;
+
+var a;
+
+// PostIncResolveNode
+a = one++;
+shouldBe("a", "1");
+shouldBe("one", "1");
+
+// PostDecResolveNode
+a = one--;
+shouldBe("a", "1");
+shouldBe("one", "1");
+
+// PreIncResolveNode
+a = ++one;
+shouldBe("a", "2");
+shouldBe("one", "1");
+
+// PreDecResolveNode
+a = --one;
+shouldBe("a", "0");
+shouldBe("one", "1");
+
+// ReadModifyConstNode
+a = one += 2;
+shouldBe("a", "3");
+shouldBe("one", "1");
+
+// AssignConstNode
+a = one = 2;
+shouldBe("a", "2");
+shouldBe("one", "1");
+
+// PostIncResolveNode
+shouldBe("function f() { const one = 1; one++; return one; } f();", "1");
+shouldBe("function f() { const oneString = '1'; return oneString++; } f();", "1");
+shouldBe("function f() { const one = 1; return one++; } f();", "1");
+
+// PostDecResolveNode
+shouldBe("function f() { const one = 1; one--; return one; } f();", "1");
+shouldBe("function f() { const oneString = '1'; return oneString--; } f();", "1");
+shouldBe("function f() { const one = 1; return one--; } f();", "1");
+
+// PreIncResolveNode
+shouldBe("function f() { const one = 1; ++one; return one; } f();", "1");
+shouldBe("function f() { const one = 1; return ++one; } f();", "2");
+
+// PreDecResolveNode
+shouldBe("function f() { const one = 1; --one; return one; } f();", "1");
+shouldBe("function f() { const one = 1; return --one; } f();", "0");
+
+// ReadModifyConstNode
+shouldBe("function f() { const one = 1; one += 2; return one; } f();", "1");
+shouldBe("function f() { const one = 1; return one += 2; } f();", "3");
+
+// AssignConstNode
+shouldBe("function f() { const one = 1; one = 2; return one; } f();", "1");
+shouldBe("function f() { const one = 1; return one = 2; } f();", "2");
+
+// PostIncResolveNode
+shouldBe("one++", "1");
+shouldBe("one", "1");
+
+// PostDecResolveNode
+shouldBe("one--", "1");
+shouldBe("one", "1");
+
+// PreIncResolveNode
+shouldBe("++one", "2");
+shouldBe("one", "1");
+
+// PreDecResolveNode
+shouldBe("--one", "0");
+shouldBe("one", "1");
+
+// ReadModifyConstNode
+shouldBe("one += 1", "2");
+shouldBe("one", "1");
+
+// AssignConstNode
+shouldBe("one = 2", "2");
+shouldBe("one", "1");
+
+var object = { inWith1: "RIGHT", inWith2: ""}
+with (object) {
+ const inWith1 = "WRONG";
+ const inWith2 = "RIGHT";
+ inWith2 = "WRONG";
+}
+shouldBe("object.inWith1", "'RIGHT'");
+shouldBe("inWith2", "'RIGHT'");
+
+shouldBe("(function(){ one = 2; return one; })()", "1")
+var f = function g() { g="FAIL"; return g; };
+shouldBe("f()", "f");
+
+shouldBe("const a;", "undefined");
+
+// Make sure that dynamic scopes (catch, with) don't break const declarations
+function tryCatch1() {
+ var bar;
+ eval("try {\
+ stuff();\
+ } catch (e) {\
+ const bar = 5;\
+ }");
+ return bar;
+}
+
+function tryCatch2() {
+ var bar;
+ try {
+ stuff();
+ } catch (e) {
+ const bar = 5;
+ }
+ return bar;
+}
+
+tryCatch1Result = tryCatch1();
+shouldBe("tryCatch1Result", "5");
+tryCatch2Result = tryCatch2();
+shouldBe("tryCatch2Result", "5");
+
+function with1() {
+ var bar;
+ eval("with({foo:42}) const bar = 5;");
+ return bar;
+}
+
+function with2() {
+ var bar;
+ with({foo:42}) const bar = 5;
+ return bar;
+}
+
+with1Result = with1();
+shouldBe("with1Result", "5");
+with2Result = with2();
+shouldBe("with2Result", "5");
+
+(function () {
+ function shouldBe(aDescription, a, b)
+ {
+ if (a === b) {
+ testPassed("PASS: " + aDescription + " should be " + b + " and is.");
+ return;
+ }
+
+ testFailed("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
+ }
+
+ (function() {
+ const x = "1";
+ shouldBe("++x", ++x, 2);
+ shouldBe("--x", --x, 0);
+ shouldBe("x", x, "1");
+ shouldBe("x++", x++, 1);
+ shouldBe("x", x, "1");
+ })();
+ (function() {
+ const x = 1;
+ shouldBe("++x", ++x, 2);
+ shouldBe("x", x, 1);
+ shouldBe("x++", x++, 1);
+ shouldBe("x", x, 1);
+ })();
+})();
</ins></span></pre>
</div>
</div>
</body>
</html>