diff options
author | Shevek <[email protected]> | 2014-09-10 23:46:12 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2014-09-10 23:46:12 -0700 |
commit | 9c8391a9591e0332de4c8a9d7662a16c70780ad5 (patch) | |
tree | c9a92aeb9aa37d39fa1cc50c72c3d9b24908373a | |
parent | 8880128db2660d6a9494911fbd14bcc5aaa39c60 (diff) |
Preprocessor: Fix SQSTRING.
-rw-r--r-- | src/main/java/org/anarres/cpp/Preprocessor.java | 1 | ||||
-rw-r--r-- | src/test/java/org/anarres/cpp/PreprocessorTest.java | 21 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index 6bcf3fb..0d14b53 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -1807,6 +1807,7 @@ public class Preprocessor implements Closeable { case RSH: case RSH_EQ: case STRING: + case SQSTRING: case XOR_EQ: return tok; diff --git a/src/test/java/org/anarres/cpp/PreprocessorTest.java b/src/test/java/org/anarres/cpp/PreprocessorTest.java index 7724ab0..fee233d 100644 --- a/src/test/java/org/anarres/cpp/PreprocessorTest.java +++ b/src/test/java/org/anarres/cpp/PreprocessorTest.java @@ -150,7 +150,9 @@ public class PreprocessorTest { 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"); + testInput("LStr(x);\n", NL, I("L"), "x", ';'); + + testInput("'foo'\n", NL, SQSTRING); writer.close(); @@ -174,6 +176,12 @@ public class PreprocessorTest { } while (t.getType() != EOF); } + private void assertType(int type, Token t) { + String typeExpect = TokenType.getTokenName(type); + String typeActual = TokenType.getTokenName(t.getType()); + assertEquals("Expected " + typeExpect + " but got " + typeActual, type, t.getType()); + } + private void testInput(String in, Object... out) throws Exception { LOG.info("Input: " + in); @@ -190,12 +198,13 @@ public class PreprocessorTest { if (t.getType() != IDENTIFIER) fail("Expected IDENTIFIER " + v + ", but got " + t); assertEquals(((I) v).getText(), t.getText()); - } else if (v instanceof Character) - assertEquals(((Character) v).charValue(), t.getType()); - else if (v instanceof Integer) - assertEquals(((Number) v).intValue(), t.getType()); - else + } else if (v instanceof Character) { + assertType(((Character) v).charValue(), t); + } else if (v instanceof Integer) { + assertType(((Number) v).intValue(), t); + } else { fail("Bad object " + v.getClass()); + } } } } |