summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/regex/syntax-errors.html
blob: e18d128d46dfc85eb23ebad6608caa32b04c66b8 (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
<p>This test verifies that implicit creation of a regular expression eagerly checks for syntax errors.</p>
<p>If the test passes, you'll see pass messages below.</p>
<pre id="console"></pre>

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

function shouldThrow(program)
{
    try {
        eval(program);
        log("FAIL: " + program + " should throw an exception but didn't");
    } catch (e) {
        log("PASS: " + program + " should throw an exception and did: " + e + ".");
    }
}

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

shouldThrow('"abc".search("[")');
shouldThrow('"abc".match("[")');
</script>