diff options
author | Shevek <[email protected]> | 2008-06-11 02:18:54 +0000 |
---|---|---|
committer | Shevek <[email protected]> | 2008-06-11 02:18:54 +0000 |
commit | 4528d72b75208f21f8d5e7d72991b7d34b4e46cf (patch) | |
tree | 87ce2b4bb993922762491268a26654211a981638 /src/tests/org | |
parent | 38d3f08b4a7302c4a1578c867bdfa3d8a57cd8f9 (diff) |
new error propagation mechanism; add include list
Diffstat (limited to 'src/tests/org')
-rw-r--r-- | src/tests/org/anarres/cpp/ErrorTestCase.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tests/org/anarres/cpp/ErrorTestCase.java b/src/tests/org/anarres/cpp/ErrorTestCase.java index d5d44a3..d7d01e8 100644 --- a/src/tests/org/anarres/cpp/ErrorTestCase.java +++ b/src/tests/org/anarres/cpp/ErrorTestCase.java @@ -8,13 +8,15 @@ import static org.anarres.cpp.Token.*; public class ErrorTestCase extends BaseTestCase { - private void testError(Source source) + private void testError(Preprocessor p) throws LexerException, IOException { for (;;) { - Token tok = source.token(); + Token tok = p.token(); if (tok.getType() == EOF) break; + else if (tok.getType() == ERROR) + throw new LexerException("Error token: " + tok); } } @@ -22,12 +24,15 @@ public class ErrorTestCase extends BaseTestCase { private void testError(String input) throws Exception { StringLexerSource sl; PreprocessorListener pl; + Preprocessor p; /* Without a PreprocessorListener, throws an exception. */ sl = new StringLexerSource(input, true); + p = new Preprocessor(); + p.addInput(sl); try { - testError(sl); - fail("Lexing succeeded"); + testError(p); + fail("Lexing succeeded unexpectedly on " + input); } catch (LexerException e) { /* ignored */ @@ -35,10 +40,13 @@ public class ErrorTestCase extends BaseTestCase { /* With a PreprocessorListener, records the error. */ sl = new StringLexerSource(input, true); + p = new Preprocessor(); + p.addInput(sl); pl = new PreprocessorListener(); - sl.setListener(pl); - testError(sl); - assertTrue(pl.getErrors() > 0); + p.setListener(pl); + assertNotNull("CPP has listener", p.getListener()); + testError(p); + assertTrue("Listener has errors", pl.getErrors() > 0); } public void testErrors() throws Exception { |