mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
12 years ago
3 changed files with 97 additions and 0 deletions
@ -0,0 +1,52 @@ |
|||
/*=== |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Don't allow empty object with just comma */ |
|||
|
|||
try { |
|||
print(JSON.parse('[,]')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
/*=== |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Don't allow initial comma */ |
|||
|
|||
try { |
|||
print(JSON.parse('[,1]')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
|
|||
/*=== |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Don't allow trailing comma. |
|||
* |
|||
* Rhino allows this. |
|||
*/ |
|||
|
|||
try { |
|||
print(JSON.parse('[1,]')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
/*=== |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Don't allow successive commas (elisions) */ |
|||
|
|||
try { |
|||
print(JSON.parse('[1,,2]')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
@ -0,0 +1,19 @@ |
|||
/*=== |
|||
SyntaxError |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Empty or pure white space is a SyntaxError. */ |
|||
|
|||
try { |
|||
print(JSON.parse('')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
try { |
|||
print(JSON.parse(' \n\r\t')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
@ -0,0 +1,26 @@ |
|||
/*=== |
|||
1 |
|||
1 |
|||
SyntaxError |
|||
===*/ |
|||
|
|||
/* Allow leading and trailing whitespace, but no other garbage */ |
|||
|
|||
try { |
|||
print(JSON.parse('1')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
try { |
|||
print(JSON.parse('\t\n 1 \t\n')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
|||
try { |
|||
print(JSON.parse('1 x')); |
|||
} catch (e) { |
|||
print(e.name); |
|||
} |
|||
|
Loading…
Reference in new issue