aboutsummaryrefslogtreecommitdiff
path: root/tests/test/cpp/lex2.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test/cpp/lex2.scm')
-rw-r--r--tests/test/cpp/lex2.scm35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/test/cpp/lex2.scm b/tests/test/cpp/lex2.scm
index af6163e8..f4f9b857 100644
--- a/tests/test/cpp/lex2.scm
+++ b/tests/test/cpp/lex2.scm
@@ -14,7 +14,7 @@
(lex "10"))
(test-equal "String literal"
- (ls `(string-literal "Hello"))
+ (ls `(string-literal (encoding-prefix) "Hello"))
(lex "\"Hello\""))
@@ -31,7 +31,7 @@
(test-equal "Comment inside string"
- (ls `(string-literal "Hel/*lo"))
+ (ls `(string-literal (encoding-prefix) "Hel/*lo"))
(lex "\"Hel/*lo\""))
(test-equal "#define line"
@@ -117,7 +117,7 @@
(test-equal "Interaction of h-strings and regular strings"
(test-equal "Less than string, not h-string"
(ls '(pp-number "1")
- '(string-literal "<")
+ '(string-literal (encoding-prefix) "<")
'(punctuator ">"))
(lex "1\"<\">"))
@@ -131,7 +131,7 @@
(list (l '(punctuator "#"))
(l '(identifier "include"))
(lexeme type: 'whitespace body: " ")
- (l '(string-literal "test")))
+ (l '(string-literal (encoding-prefix) "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
@@ -142,7 +142,7 @@
(test-group "Unicode"
(test-equal "In string literals"
- (ls '(string-literal "åäö"))
+ (ls '(string-literal (encoding-prefix) "åäö"))
(lex "\"åäö\""))
(test-equal "Outside string literals"
@@ -150,3 +150,28 @@
(lexeme type: 'other body: "ä")
(lexeme type: 'other body: "ö"))
(lex "åäö")))
+
+
+
+
+(test-group "Characters with prefixes"
+ (test-equal (ls '(character-constant (character-prefix . "u")
+ "a"))
+ (lex "u'a'"))
+ (test-equal (ls '(character-constant (character-prefix . "U")
+ "a"))
+ (lex "U'a'"))
+ (test-equal (ls '(character-constant (character-prefix . "L")
+ "a"))
+ (lex "L'a'")))
+
+;; Note that these strings have 0 "data" components
+(test-group "Strings with prefixes"
+ (test-equal (ls '(string-literal (encoding-prefix . "u8")))
+ (lex "u8\"\""))
+ (test-equal (ls '(string-literal (encoding-prefix . "u")))
+ (lex "u\"\""))
+ (test-equal (ls '(string-literal (encoding-prefix . "U")))
+ (lex "U\"\""))
+ (test-equal (ls '(string-literal (encoding-prefix . "L")))
+ (lex "L\"\"")))