diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-23 21:42:19 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-08-18 16:38:37 +0200 |
commit | 39a878d1130bd33d7d1b1380617747187e01fb73 (patch) | |
tree | 5ea885ebe8eac148c6967fa7a24f6821ca24a8de /tests/test/cpp | |
parent | Rewrote H-string tests to be what they should. (diff) | |
download | calp-39a878d1130bd33d7d1b1380617747187e01fb73.tar.gz calp-39a878d1130bd33d7d1b1380617747187e01fb73.tar.xz |
Only parse h-strings where applicable.
Diffstat (limited to 'tests/test/cpp')
-rw-r--r-- | tests/test/cpp/lex2.scm | 23 | ||||
-rw-r--r-- | tests/test/cpp/preprocessor2.scm | 2 |
2 files changed, 22 insertions, 3 deletions
diff --git a/tests/test/cpp/lex2.scm b/tests/test/cpp/lex2.scm index 54bc0aff..e30aac31 100644 --- a/tests/test/cpp/lex2.scm +++ b/tests/test/cpp/lex2.scm @@ -9,6 +9,9 @@ (define (ls . xs) (map l xs)) +;; See comment on h-string-compound in (c lex2) +(test-expect-fail "H-string looking as argument to macro") + (test-equal "Integer literal" (ls '(pp-number "10")) (lex "10")) @@ -108,17 +111,33 @@ (test-equal "Propper H-string" (list (l '(punctuator "#")) (l '(identifier "include")) - (lexeme type: 'whitespace body: " ") + ;; (lexeme type: 'whitespace body: " ") (l '(h-string "a"))) (lex "#include <a>")) - (test-equal "Not a H string" (ls '(punctuator "<") '(identifier "a") '(punctuator ">")) (lex "<a>")) + ;; Assume that s is defined as + ;; #define s(x) #x + ;; then the following expression would expand to + ;; "#include<a>" + (test-equal "H-string looking as argument to macro" + (ls '(identifier "s") + '(punctuator "(") + '(punctuator "#") + '(identifier "include") + '(punctuator "<") + '(identifier "a") + '(punctuator ">") + '(punctuator ")")) + (lex "s(#include<a>)")) + + ;; The standard says this case is undefined + ;; 6.4.7 p. 3 (test-equal "Quotation mark inside h-string" (ls '(punctuator "#") '(identifier "include") diff --git a/tests/test/cpp/preprocessor2.scm b/tests/test/cpp/preprocessor2.scm index fd18ddce..be5ba94c 100644 --- a/tests/test/cpp/preprocessor2.scm +++ b/tests/test/cpp/preprocessor2.scm @@ -591,7 +591,7 @@ (test-equal "H-string" "/usr/include/stdio.h" (resolve-header (make-environment) - (lex "<stdio.h>"))) + (cddr (lex "#include <stdio.h>")))) (test-equal "Q-string" "/usr/include/stdio.h" (resolve-header (make-environment) |