michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Check that simple JS can be parsed and cached with the reflection API. michael@0: */ michael@0: michael@0: function test() { michael@0: let { Parser } = Cu.import("resource:///modules/devtools/Parser.jsm", {}); michael@0: michael@0: let source = "let x = 42;"; michael@0: let parser = new Parser(); michael@0: let first = parser.get(source); michael@0: let second = parser.get(source); michael@0: michael@0: isnot(first, second, michael@0: "The two syntax trees should be different."); michael@0: michael@0: let third = parser.get(source, "url"); michael@0: let fourth = parser.get(source, "url"); michael@0: michael@0: isnot(first, third, michael@0: "The new syntax trees should be different than the old ones."); michael@0: is(third, fourth, michael@0: "The new syntax trees were cached once an identifier was specified."); michael@0: michael@0: is(parser.errors.length, 0, michael@0: "There should be no errors logged when parsing."); michael@0: michael@0: finish(); michael@0: }