1 // |reftest| skip-if(!xulRuntime.shell)
4 // Source location information
5 var withoutFileOrLine = Reflect.parse("42");
6 var withFile = Reflect.parse("42", {source:"foo.js"});
7 var withFileAndLine = Reflect.parse("42", {source:"foo.js", line:111});
9 Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withoutFileOrLine.loc);
10 Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 1, column: 2 } }).match(withFile.loc);
11 Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 111, column: 2 } }).match(withFileAndLine.loc);
13 var withoutFileOrLine2 = Reflect.parse("foo +\nbar");
14 var withFile2 = Reflect.parse("foo +\nbar", {source:"foo.js"});
15 var withFileAndLine2 = Reflect.parse("foo +\nbar", {source:"foo.js", line:111});
17 Pattern({ source: null, start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withoutFileOrLine2.loc);
18 Pattern({ source: "foo.js", start: { line: 1, column: 0 }, end: { line: 2, column: 3 } }).match(withFile2.loc);
19 Pattern({ source: "foo.js", start: { line: 111, column: 0 }, end: { line: 112, column: 3 } }).match(withFileAndLine2.loc);
21 var nested = Reflect.parse("(-b + sqrt(sqr(b) - 4 * a * c)) / (2 * a)", {source:"quad.js"});
22 var fourAC = nested.body[0].expression.left.right.arguments[0].right;
24 Pattern({ source: "quad.js", start: { line: 1, column: 20 }, end: { line: 1, column: 29 } }).match(fourAC.loc);
28 assertEq("loc" in Reflect.parse("42", {loc:false}), false);
29 program([exprStmt(lit(42))]).assert(Reflect.parse("42", {loc:false}));