diff options
Diffstat (limited to '')
-rw-r--r-- | tests/test/cpp/lex2.scm | 76 |
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 ")) |