browser/devtools/debugger/test/browser_dbg_parser-01.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-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     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 simple JS can be parsed and cached with the reflection API.
     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 first = parser.get(source);
    1.17 +  let second = parser.get(source);
    1.18 +
    1.19 +  isnot(first, second,
    1.20 +    "The two syntax trees should be different.");
    1.21 +
    1.22 +  let third = parser.get(source, "url");
    1.23 +  let fourth = parser.get(source, "url");
    1.24 +
    1.25 +  isnot(first, third,
    1.26 +    "The new syntax trees should be different than the old ones.");
    1.27 +  is(third, fourth,
    1.28 +    "The new syntax trees were cached once an identifier was specified.");
    1.29 +
    1.30 +  is(parser.errors.length, 0,
    1.31 +    "There should be no errors logged when parsing.");
    1.32 +
    1.33 +  finish();
    1.34 +}

mercurial