aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/org/anarres/cpp/ErrorTestCase.java18
-rw-r--r--src/tests/org/anarres/cpp/PreprocessorTestCase.java12
2 files changed, 16 insertions, 14 deletions
diff --git a/src/tests/org/anarres/cpp/ErrorTestCase.java b/src/tests/org/anarres/cpp/ErrorTestCase.java
index 6adc912..ad042be 100644
--- a/src/tests/org/anarres/cpp/ErrorTestCase.java
+++ b/src/tests/org/anarres/cpp/ErrorTestCase.java
@@ -8,17 +8,17 @@ import static org.anarres.cpp.Token.*;
public class ErrorTestCase extends BaseTestCase {
- private void testError(Preprocessor p)
+ private boolean testError(Preprocessor p)
throws LexerException,
IOException {
for (;;) {
Token tok = p.token();
if (tok.getType() == EOF)
break;
- else if (tok.getType() == INVALID)
- throw new LexerException("Error token: " + tok);
+ if (tok.getType() == INVALID)
+ return true;
}
-
+ return false;
}
private void testError(String input) throws Exception {
@@ -29,23 +29,25 @@ public class ErrorTestCase extends BaseTestCase {
/* Without a PreprocessorListener, throws an exception. */
sl = new StringLexerSource(input, true);
p = new Preprocessor();
+ p.addFeature(Feature.CSYNTAX);
p.addInput(sl);
try {
- testError(p);
- fail("Lexing succeeded unexpectedly on " + input);
+ assertTrue(testError(p));
+ fail("Lexing unexpectedly succeeded without listener.");
}
catch (LexerException e) {
- /* ignored */
+ /* required */
}
/* With a PreprocessorListener, records the error. */
sl = new StringLexerSource(input, true);
p = new Preprocessor();
+ p.addFeature(Feature.CSYNTAX);
p.addInput(sl);
pl = new PreprocessorListener();
p.setListener(pl);
assertNotNull("CPP has listener", p.getListener());
- testError(p);
+ assertTrue(testError(p));
assertTrue("Listener has errors", pl.getErrors() > 0);
}
diff --git a/src/tests/org/anarres/cpp/PreprocessorTestCase.java b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
index ff2bc10..e07b085 100644
--- a/src/tests/org/anarres/cpp/PreprocessorTestCase.java
+++ b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
@@ -81,20 +81,20 @@ public class PreprocessorTestCase extends BaseTestCase {
/* Redefinitions, undefinitions. */
testInput("#define two three\n", NL);
-testInput("one /* one */\n", NL, I("one"), WHITESPACE, COMMENT);
+testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT);
testInput("#define one two\n", NL);
-testInput("one /* three */\n", NL, I("three"), WHITESPACE, COMMENT);
+testInput("one /* three */\n", NL, I("three"), WHITESPACE, CCOMMENT);
testInput("#undef two\n", NL);
testInput("#define two five\n", NL);
-testInput("one /* five */\n", NL, I("five"), WHITESPACE, COMMENT);
+testInput("one /* five */\n", NL, I("five"), WHITESPACE, CCOMMENT);
testInput("#undef two\n", NL);
-testInput("one /* two */\n", NL, I("two"), WHITESPACE, COMMENT);
+testInput("one /* two */\n", NL, I("two"), WHITESPACE, CCOMMENT);
testInput("#undef one\n", NL);
testInput("#define one four\n", NL);
-testInput("one /* four */\n", NL, I("four"), WHITESPACE, COMMENT);
+testInput("one /* four */\n", NL, I("four"), WHITESPACE, CCOMMENT);
testInput("#undef one\n", NL);
testInput("#define one one\n", NL);
-testInput("one /* one */\n", NL, I("one"), WHITESPACE, COMMENT);
+testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT);
/* Variadic macros. */
testInput("#define var(x...) a x b\n", NL);