From 491b867a503a082f3bdd87df77d1cebca7955e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 23 Jul 2022 20:50:16 +0200 Subject: Rewrote H-string tests to be what they should. H-strings can only appear as part of an #include statement. The previous tests checked how my implementation worked, not how it should have worked. --- tests/test/cpp/lex2.scm | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/tests/test/cpp/lex2.scm b/tests/test/cpp/lex2.scm index f4f9b857..54bc0aff 100644 --- a/tests/test/cpp/lex2.scm +++ b/tests/test/cpp/lex2.scm @@ -97,35 +97,33 @@ (l '(identifier "dir"))) (lex "..\\listing.dir")) +(test-group "h-strings" -(test-equal "Propper H-string" - (ls '(header-name (h-string "a"))) - (lex "")) + ;; A hstring is the part enclosed by pointy brackets in + ;; #include + ;; (e.g. "header.h") + ;; Something with the form anywhere else should be + ;; treated as (token <) (token chars) (token >) -(test-equal "Unexpected h-string" - (list (l '(pp-number "1")) - (lexeme type: 'whitespace body: " ") - (l '(header-name (h-string " 2 "))) - (lexeme type: 'whitespace body: " ") - (l '(pp-number "3"))) - (lex "1 < 2 > 3")) + (test-equal "Propper H-string" + (list (l '(punctuator "#")) + (l '(identifier "include")) + (lexeme type: 'whitespace body: " ") + (l '(h-string "a"))) + (lex "#include ")) -(test-equal "Quotation mark inside h-string" - (ls '(header-name (h-string "a\"b"))) - (lex "")) -(test-equal "Interaction of h-strings and regular strings" - (test-equal "Less than string, not h-string" - (ls '(pp-number "1") - '(string-literal (encoding-prefix) "<") + (test-equal "Not a H string" + (ls '(punctuator "<") + '(identifier "a") '(punctuator ">")) - (lex "1\"<\">")) + (lex "")) - (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 "Quotation mark inside h-string" + (ls '(punctuator "#") + '(identifier "include") + '(h-string "a\"b")) + (lex "#include"))) (test-equal "Q-strings are lexed as regular strings" (list (l '(punctuator "#")) -- cgit v1.2.3