chromium/third_party/blink/web_tests/fast/js/do-while-expression-value.html

<p>This page tests the evaluated value of a do-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;

x = eval("do { 1; } while(0);");
shouldBe("x", 1);

var x = eval("do { 1; break; } while(0);");
shouldBe("x", 1);

var x = eval("do { 1; continue; } while(0);");
shouldBe("x", 1);

var x = eval("do { 1; ; } while(0);");
shouldBe("x", 1);

</script>