mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
460 B
34 lines
460 B
/*
|
|
* Test JSON error byte offset
|
|
*/
|
|
|
|
/*---
|
|
{
|
|
"custom": true
|
|
}
|
|
---*/
|
|
|
|
/*===
|
|
SyntaxError: invalid json (at offset 11)
|
|
SyntaxError: invalid json (at offset 17)
|
|
===*/
|
|
|
|
function test1() {
|
|
JSON.parse('[ "\ufedcfoo"; ]'); // error at char offset 8, byte offset, 11
|
|
}
|
|
|
|
function test2() {
|
|
JSON.parse('{ "foo": "bar" } x'); // error at byte offset 17
|
|
}
|
|
|
|
try {
|
|
test1();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
|
|
try {
|
|
test2();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
|