summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/js/while-expression-value.html
blob: d92e13fae7fa35aa4f93e9bb00925df586528565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<p>This page tests the evaluated value of a while expression.</p>
<pre id="console"></pre>

<script>
if (window.testRunner)
    testRunner.dumpAsText();

function log(s)
{
    document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}

function shouldBe(a, b)
{
    var evalA;
    try {
        evalA = eval(a);
    } catch(e) {
        evalA = e;
    }
    
    if (evalA === b) {
        log("PASS: " + a + " should be " + b + " and is.");
    } else {
        log("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".");
    }
}

var x, condition;

condition = true;
x = eval("while (condition) { condition = false; 1; }");
shouldBe("x", 1);

condition = true;
var x = eval("while (condition) { condition = false; 1; break; }");
shouldBe("x", 1);

condition = true;
var x = eval("while (condition) { condition = false; 1; continue; }");
shouldBe("x", 1);

condition = true;
var x = eval("while (condition) { condition = false; 1; ; }");
shouldBe("x", 1);

</script>