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.
37 lines
638 B
37 lines
638 B
11 years ago
|
/*
|
||
|
* SyntaxErrors thrown during parsing get their message augmented with a
|
||
|
* line indicating where the syntax error occurred.
|
||
|
*/
|
||
|
|
||
|
/*---
|
||
|
{
|
||
|
"custom": true
|
||
|
}
|
||
|
---*/
|
||
|
|
||
|
/*===
|
||
|
line 1
|
||
|
line 2
|
||
|
line 4
|
||
|
===*/
|
||
|
|
||
|
function test(inp) {
|
||
|
try {
|
||
|
eval(inp);
|
||
|
print('never here');
|
||
|
} catch (e) {
|
||
|
// Match against current syntax
|
||
|
res = /^.*\(line (\d+)\)$/.exec(e.message);
|
||
|
print('line', res ? res[1] : 'n/a');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
// Test for specific line numbers; these may change at some point due to compiler details
|
||
|
test('"foo');
|
||
|
test('\n"foo');
|
||
|
test('\n\n1\n+');
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|