chromium/third_party/blink/web_tests/fast/js/trivial-functions.html

<p>Tests for compilation errors in trivial functions.</p>
<pre id="console"></pre>

<p id="p"></p>

<script>
function $(id)
{
    return document.getElementById(id);
}

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

function shouldBe(aDescription, a, b)
{
    if (a == b) {
        log("PASS: " + aDescription + " should be " + b + " and is.");
        return;
    }

    log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}

function f1(a, b) { return a[b]; }
function f2(a, b, c) { return a[b] = c; }

if (window.testRunner)
    testRunner.dumpAsText();

shouldBe("f1(0, 0)", f1(0, 0), undefined);
shouldBe("f2(0, 0, 0)", f2(0, 0, 0), 0);
</script>