added position property to ParseError

This commit is contained in:
Kevin Barabash 2014-09-22 09:41:26 -06:00
parent d2f41a19a5
commit afaec30d0a
2 changed files with 12 additions and 0 deletions

View File

@ -29,6 +29,8 @@ function ParseError(message, lexer, position) {
var self = new Error(error);
self.name = "ParseError";
self.__proto__ = ParseError.prototype;
self.position = position;
return self;
}

View File

@ -1040,3 +1040,13 @@ describe("An accent builder", function() {
expect(getBuilt("\\vec )^2")[0].classes).not.toContain("mclose");
});
});
describe("A parser error", function () {
it("should report the position of an error", function () {
try {
parseTree("\\sqrt}");
} catch (e) {
expect(e.position).toEqual(5);
}
});
});