diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test/cpp/lex2.scm | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test/cpp/lex2.scm b/tests/test/cpp/lex2.scm index 47bb4a16..b7087c3b 100644 --- a/tests/test/cpp/lex2.scm +++ b/tests/test/cpp/lex2.scm @@ -92,3 +92,57 @@ (lexeme type: 'preprocessing-token body: '(punctuator ".")) (lexeme type: 'preprocessing-token body: '(identifier "dir"))) (lex "..\\listing.dir")) + + +(test-equal "Propper H-string" + (list (lexeme type: 'preprocessing-token body: '(header-name (h-string "a")))) + (lex "<a>")) + +(test-equal "Unexpected h-string" + (list (lexeme type: 'preprocessing-token body: '(pp-number "1")) + (lexeme type: 'whitespace body: " ") + (lexeme type: 'preprocessing-token body: '(header-name (h-string " 2 "))) + (lexeme type: 'whitespace body: " ") + (lexeme type: 'preprocessing-token body: '(pp-number "3"))) + (lex "1 < 2 > 3")) + +(test-equal "Quotation mark inside h-string" + (list (lexeme type: 'preprocessing-token body: '(header-name (h-string "a\"b")))) + (lex "<a\"b>")) + +(test-equal "Interaction of h-strings and regular strings" + (test-equal "Less than string, not h-string" + (list (lexeme type: 'preprocessing-token body: '(pp-number "1")) + (lexeme type: 'preprocessing-token body: '(string-literal "<")) + (lexeme type: 'preprocessing-token body: '(punctuator ">"))) + (lex "1\"<\">")) + + (test-equal "H-string, not string" + (list (lexeme type: 'preprocessing-token body: '(pp-number "1")) + (lexeme type: 'preprocessing-token body: '(header-name (h-string "\""))) + (lexeme type: 'other body: "\"")) + (lex "1<\">\""))) + +(test-equal "Q-strings are lexed as regular strings" + (list (lexeme type: 'preprocessing-token body: '(punctuator "#")) + (lexeme type: 'preprocessing-token body: '(identifier "include")) + (lexeme type: 'whitespace body: " ") + (lexeme type: 'preprocessing-token body: '(string-literal "test"))) + ;; # include here, since generated tokens could possible depend on that context, + ;; and the reason regular strings are returned is since the lexer doesn't check + ;; that context + (lex "#include \"test\"") + ) + + + +(test-group "Unicode" + (test-equal "In string literals" + (list (lexeme type: 'preprocessing-token body: '(string-literal "åäö"))) + (lex "\"åäö\"")) + + (test-equal "Outside string literals" + (list (lexeme type: 'other body: "å") + (lexeme type: 'other body: "ä") + (lexeme type: 'other body: "ö")) + (lex "åäö"))) |