Fix delimiter error message (#2186)

* Fix delimiter error message

Avoid "circular structure" error message by avoiding JSON.stringify on a
parse structure when getting an invalid delimiter type (e.g. ordgroup).
Instead, report type of delimiter when it's invalid.  Fixes #2184.

* Fix and add tests
This commit is contained in:
Erik Demaine
2020-01-04 04:10:11 -05:00
committed by ylemkimon
parent 754e79a12e
commit 3cb9bd78bb
2 changed files with 17 additions and 6 deletions

View File

@@ -250,14 +250,24 @@ describe("functions.js:", function() {
describe("delimiter functions", function() {
it("reject invalid opening delimiters", function() {
expect`\bigl 1 + 2 \bigr`.toFailWithParseError(
"Invalid delimiter: '1' after '\\bigl' at position 7:" +
"Invalid delimiter '1' after '\\bigl' at position 7:" +
" \\bigl 1̲ + 2 \\bigr");
});
it("reject invalid closing delimiters", function() {
expect`\bigl(1+2\bigr=3`.toFailWithParseError(
"Invalid delimiter: '=' after '\\bigr' at position 15:" +
"Invalid delimiter '=' after '\\bigr' at position 15:" +
" \\bigl(1+2\\bigr=̲3");
});
it("reject group opening delimiters", function() {
expect`\bigl{(}1+2\bigr)3`.toFailWithParseError(
"Invalid delimiter type 'ordgroup' at position 6:" +
" \\bigl{̲(̲}̲1+2\\bigr)3");
});
it("reject group closing delimiters", function() {
expect`\bigl(1+2\bigr{)}3`.toFailWithParseError(
"Invalid delimiter type 'ordgroup' at position 15:" +
" \\bigl(1+2\\bigr{̲)̲}̲3");
});
});
describe("\\begin and \\end", function() {