aboutsummaryrefslogtreecommitdiff
path: root/tests/test/cpp/lex2.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-07-10 23:36:56 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-10 23:36:56 +0200
commitf7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9 (patch)
treedcc40399f08285a9a308079098e735fb5bf192bd /tests/test/cpp/lex2.scm
parentAdd of-type? to (hnh util type). (diff)
downloadcalp-f7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9.tar.gz
calp-f7b18cc72dd5b2ca90b6670dbe81c3ef3204d6d9.tar.xz
Resolve recursive macros.
Diffstat (limited to 'tests/test/cpp/lex2.scm')
-rw-r--r--tests/test/cpp/lex2.scm76
1 files changed, 39 insertions, 37 deletions
diff --git a/tests/test/cpp/lex2.scm b/tests/test/cpp/lex2.scm
index 762ff176..b80bcf37 100644
--- a/tests/test/cpp/lex2.scm
+++ b/tests/test/cpp/lex2.scm
@@ -6,60 +6,62 @@
(test-equal "Integer literal"
- '((preprocessing-token (pp-number "10")))
+ (list (lexeme type: 'preprocessing-token body: '(pp-number "10")))
(lex "10"))
(test-equal "String literal"
- '((preprocessing-token (string-literal "Hello")))
+ (list (lexeme type: 'preprocessing-token body: '(string-literal "Hello")))
(lex "\"Hello\""))
(test-equal "Mulitple tokens, including whitespace"
- '((whitespace " ")
- (preprocessing-token (pp-number "10"))
- (whitespace " "))
+ (list (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(pp-number "10"))
+ (lexeme type: 'whitespace body: " "))
(lex " 10 "))
(test-equal "Char literal"
- '((preprocessing-token (character-constant "a")))
+ (list (lexeme type: 'preprocessing-token body: '(character-constant "a")))
(lex "'a'"))
(test-equal "Comment inside string"
- '((preprocessing-token (string-literal "Hel/*lo")))
+ (list (lexeme type: 'preprocessing-token body: '(string-literal "Hel/*lo")))
(lex "\"Hel/*lo\""))
(test-equal "#define line"
- '((preprocessing-token (punctuator "#"))
- (preprocessing-token (identifier "define"))
- (whitespace " ")
- (preprocessing-token (identifier "f"))
- (preprocessing-token (punctuator "("))
- (preprocessing-token (identifier "x"))
- (preprocessing-token (punctuator ")"))
- (whitespace " ")
- (preprocessing-token (pp-number "10")))
+ (list
+ (lexeme type: 'preprocessing-token body: '(punctuator "#"))
+ (lexeme type: 'preprocessing-token body: '(identifier "define"))
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(identifier "f"))
+ (lexeme type: 'preprocessing-token body: '(punctuator "("))
+ (lexeme type: 'preprocessing-token body: '(identifier "x"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ")"))
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(pp-number "10")))
(lex "#define f(x) 10"))
(test-equal "Nested parenthesis"
- '((preprocessing-token (identifier "f"))
- (preprocessing-token (punctuator "("))
- (preprocessing-token (pp-number "1"))
- (preprocessing-token (punctuator ","))
- (whitespace " ")
- (preprocessing-token (punctuator "("))
- (preprocessing-token (pp-number "2"))
- (preprocessing-token (punctuator ","))
- (whitespace " ")
- (preprocessing-token (pp-number "3"))
- (preprocessing-token (punctuator ")"))
- (preprocessing-token (punctuator ","))
- (whitespace " ")
- (preprocessing-token (pp-number "4"))
- (preprocessing-token (punctuator ")")))
+ (list
+ (lexeme type: 'preprocessing-token body: '(identifier "f"))
+ (lexeme type: 'preprocessing-token body: '(punctuator "("))
+ (lexeme type: 'preprocessing-token body: '(pp-number "1"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ","))
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(punctuator "("))
+ (lexeme type: 'preprocessing-token body: '(pp-number "2"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ","))
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(pp-number "3"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ")"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ","))
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'preprocessing-token body: '(pp-number "4"))
+ (lexeme type: 'preprocessing-token body: '(punctuator ")")))
(lex "f(1, (2, 3), 4)"))
@@ -68,13 +70,13 @@
;; (whitespace " ")
;; would also be ok
(test-equal "Grouped whitespace"
- '((whitespace " ")
- (whitespace " "))
+ (list (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'whitespace body: " "))
(lex " "))
(test-equal "Newlines get sepparate whitespace tokens"
- '((whitespace " ")
- (whitespace " ")
- (whitespace "\n")
- (whitespace " "))
+ (list (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'whitespace body: " ")
+ (lexeme type: 'whitespace body: "\n")
+ (lexeme type: 'whitespace body: " "))
(lex " \n "))