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 syntax errors are reported correctly. 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 parsed = parser.get(source); michael@0: michael@0: ok(parsed, michael@0: "An object should be returned even though the source had a syntax error."); michael@0: michael@0: is(parser.errors.length, 1, michael@0: "There should be one error logged when parsing."); michael@0: is(parser.errors[0].name, "SyntaxError", michael@0: "The correct exception was caught."); michael@0: is(parser.errors[0].message, "missing ; before statement", michael@0: "The correct exception was caught."); michael@0: michael@0: finish(); michael@0: }