From 37dc6cc5ab804da964f22787561d030898115809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 20 Jul 2022 16:25:35 +0200 Subject: Acknowledge string prefixes. --- tests/test/cpp/lex2.scm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'tests/test/cpp/lex2.scm') 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\"\""))) -- cgit v1.2.3