browser/devtools/debugger/test/browser_dbg_parser-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_parser-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,26 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Check that syntax errors are reported correctly.
     1.9 + */
    1.10 +
    1.11 +function test() {
    1.12 +  let { Parser } = Cu.import("resource:///modules/devtools/Parser.jsm", {});
    1.13 +
    1.14 +  let source = "let x + 42;";
    1.15 +  let parser = new Parser();
    1.16 +  let parsed = parser.get(source);
    1.17 +
    1.18 +  ok(parsed,
    1.19 +    "An object should be returned even though the source had a syntax error.");
    1.20 +
    1.21 +  is(parser.errors.length, 1,
    1.22 +    "There should be one error logged when parsing.");
    1.23 +  is(parser.errors[0].name, "SyntaxError",
    1.24 +    "The correct exception was caught.");
    1.25 +  is(parser.errors[0].message, "missing ; before statement",
    1.26 +    "The correct exception was caught.");
    1.27 +
    1.28 +  finish();
    1.29 +}

mercurial