summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorShevek <[email protected]>2009-04-08 12:24:53 +0000
committerShevek <[email protected]>2009-04-08 12:24:53 +0000
commit130f6b820dcb1a835b7bd9333f0cb9702793e262 (patch)
tree155f0f68ba65c56ca7d588ff9c33f0910a2ecc53 /src/tests
parentd46bffd718bb44013c981d4f29bd8d58b39bd3b6 (diff)
fix widening macro case
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/org/anarres/cpp/PreprocessorTestCase.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/tests/org/anarres/cpp/PreprocessorTestCase.java b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
index e07b085..63e4009 100644
--- a/src/tests/org/anarres/cpp/PreprocessorTestCase.java
+++ b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
@@ -33,12 +33,22 @@ public class PreprocessorTestCase extends BaseTestCase {
public String getText() {
return t;
}
+ public String toString() {
+ return getText();
+ }
}
private static I I(String t) {
return new I(t);
}
+/*
+ * When writing tests in this file, remember the preprocessor
+ * stashes NLs, so you won't see an immediate NL at the end of any
+ * input line. You will see it right before the next nonblank on
+ * the following input line.
+ */
+
public void testPreprocessor() throws Exception {
/* Magic macros */
testInput("line = __LINE__\n",
@@ -98,7 +108,7 @@ testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT);
/* Variadic macros. */
testInput("#define var(x...) a x b\n", NL);
- testInput("var(e, f, g)", NL,
+ testInput("var(e, f, g)\n", NL,
I("a"), WHITESPACE,
I("e"), ',', WHITESPACE,
I("f"), ',', WHITESPACE,
@@ -106,6 +116,11 @@ testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT);
I("b")
);
+ testInput("#define _Widen(x) L ## x\n", NL);
+ testInput("#define Widen(x) _Widen(x)\n", NL);
+ testInput("#define LStr(x) _Widen(#x)\n", NL);
+ testInput("LStr(x);\n", NL, I("L"), "x");
+
writer.close();
Token t;
@@ -131,7 +146,7 @@ testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT);
}
else if (v instanceof I) {
if (t.getType() != IDENTIFIER)
- fail("Expected IDENTIFIER, but got " + t);
+ fail("Expected IDENTIFIER " + v + ", but got " + t);
assertEquals( ((I)v).getText(), (String)t.getText());
}
else if (v instanceof Character)