Added tests for missing 'try' parsing

This commit is contained in:
Daniel Rosenwasser
2014-07-25 18:25:43 -07:00
parent efb6db8757
commit 0939f77d77
2 changed files with 49 additions and 3 deletions
@@ -1,4 +1,4 @@
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (2 errors) ====
==== tests/cases/conformance/statements/tryStatements/invalidTryStatements2.ts (6 errors) ====
function fn() {
try {
} catch { // syntax error, missing '(x)'
@@ -10,5 +10,32 @@
~~~~~
!!! A 'catch' clause must be preceded by a 'try' statement.
finally{ } // error missing try
finally{ } // potential error; can be absorbed by the 'catch'
}
function fn2() {
finally { } // error missing try
~~~~~~~
!!! A 'finally' block must be preceded by a 'try' statement.
catch (x) { } // error missing try
~~~~~
!!! A 'catch' clause must be preceded by a 'try' statement.
// no error
try {
}
finally {
}
// error missing try
finally {
~~~~~~~
!!! A 'finally' block must be preceded by a 'try' statement.
}
// error missing try
catch (x) {
~~~~~
!!! A 'catch' clause must be preceded by a 'try' statement.
}
}
@@ -5,5 +5,24 @@ function fn() {
catch(x) { } // error missing try
finally{ } // error missing try
finally{ } // potential error; can be absorbed by the 'catch'
}
function fn2() {
finally { } // error missing try
catch (x) { } // error missing try
// no error
try {
}
finally {
}
// error missing try
finally {
}
// error missing try
catch (x) {
}
}