aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-23 20:50:16 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-08-18 16:38:37 +0200
commit491b867a503a082f3bdd87df77d1cebca7955e93 (patch)
tree1ca6d07659ae7f83a205c25f26d7dd5d12b7181b
parentAdd propper error messaging when pre-processor fails. (diff)
downloadcalp-491b867a503a082f3bdd87df77d1cebca7955e93.tar.gz
calp-491b867a503a082f3bdd87df77d1cebca7955e93.tar.xz
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.
-rw-r--r--tests/test/cpp/lex2.scm44
1 files 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>"))
+ ;; A hstring is the part enclosed by pointy brackets in
+ ;; #include <header.h>
+ ;; (e.g. "header.h")
+ ;; Something with the form <chars> 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 <a>"))
-(test-equal "Quotation mark inside h-string"
- (ls '(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"
- (ls '(pp-number "1")
- '(string-literal (encoding-prefix) "<")
+ (test-equal "Not a H string"
+ (ls '(punctuator "<")
+ '(identifier "a")
'(punctuator ">"))
- (lex "1\"<\">"))
+ (lex "<a>"))
- (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<a\"b>")))
(test-equal "Q-strings are lexed as regular strings"
(list (l '(punctuator "#"))