Fix TestSyntaxError() and TestSyntaxErrorDeclaringVariableInForLoop()

They were all failing assertions but the exceptions these threw were caught as expected Exceptions.
I don't think we can easily distinguish these from the Exceptions that we're expecting.
So for now we'll do some messy manually checking with boolean setting instead.
This patch also corrects the assertions themselves.
0.7.3-post-fixes
Justin Clark-Casey (justincc) 2012-03-06 02:30:22 +00:00
parent 9992974c66
commit 0116d418f0
1 changed files with 14 additions and 8 deletions

View File

@ -1744,11 +1744,12 @@ default
}
[Test]
[ExpectedException(typeof(System.Exception))]
public void TestSyntaxError()
{
TestHelpers.InMethod();
bool gotException = false;
string input = @"default
{
state_entry()
@ -1764,19 +1765,22 @@ default
}
catch (System.Exception e)
{
// The syntax error is on line 6, char 5 (expected ';', found
// The syntax error is on line 5, char 4 (expected ';', found
// '}').
Assert.AreEqual("(4,4) syntax error", e.Message);
throw;
Assert.AreEqual("(5,4) syntax error", e.Message);
gotException = true;
}
Assert.That(gotException, Is.True);
}
[Test]
[ExpectedException(typeof(System.Exception))]
public void TestSyntaxErrorDeclaringVariableInForLoop()
{
TestHelpers.InMethod();
bool gotException = false;
string input = @"default
{
state_entry()
@ -1792,11 +1796,13 @@ default
}
catch (System.Exception e)
{
// The syntax error is on line 5, char 14 (Syntax error)
Assert.AreEqual("(3,13) syntax error", e.Message);
// The syntax error is on line 4, char 13 (Syntax error)
Assert.AreEqual("(4,13) syntax error", e.Message);
throw;
gotException = true;
}
Assert.That(gotException, Is.True);
}
}
}