aboutsummaryrefslogtreecommitdiff
path: root/tests/test/cpp/preprocessor2.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test/cpp/preprocessor2.scm')
-rw-r--r--tests/test/cpp/preprocessor2.scm45
1 files changed, 33 insertions, 12 deletions
diff --git a/tests/test/cpp/preprocessor2.scm b/tests/test/cpp/preprocessor2.scm
index 27332894..1df1a621 100644
--- a/tests/test/cpp/preprocessor2.scm
+++ b/tests/test/cpp/preprocessor2.scm
@@ -119,35 +119,44 @@
(test-group "Parse identifier list"
(test-group "Single argument"
- (let ((rest args (parse-identifier-list (lex "x"))))
+ (let ((rest args remaining (parse-identifier-list (lex "(x)"))))
(test-assert (not rest))
- (test-equal '("x") args)))
+ (test-equal '("x") args)
+ (test-equal '() remaining)))
(test-group "Multiple parameters"
- (let ((rest args (parse-identifier-list (lex "x, y"))))
+ (let ((rest args remaining (parse-identifier-list (lex "(x, y)"))))
(test-assert (not rest))
- (test-equal '("x" "y") args)))
+ (test-equal '("x" "y") args)
+ (test-equal '() remaining)))
+ (test-group "Zero parameters"
+ (let ((rest args remaining (parse-identifier-list (lex "()"))))
+ (test-assert (not rest))
+ (test-equal '() args)
+ (test-equal '() remaining)))
(test-group "Rest args after regular"
- (let ((rest args (parse-identifier-list (lex "x, ..."))))
+ (let ((rest args remaining (parse-identifier-list (lex "(x, ...)"))))
(test-assert rest)
- (test-equal '("x") args)))
+ (test-equal '("x") args)
+ (test-equal '() remaining)))
(test-group "Only rest args"
- (let ((rest args (parse-identifier-list (lex "..."))))
+ (let ((rest args remaining (parse-identifier-list (lex "(...)"))))
(test-assert rest)
- (test-equal '() args)))
+ (test-equal '() args)
+ (test-equal '() remaining)))
(test-group "Errors"
(test-error "Compound forms are invalid"
- 'cpp-error (parse-identifier-list (lex "(y)")))
+ 'wrong-type-arg (parse-identifier-list (lex "((y))")))
(test-error "Non-identifier atoms are invalid"
- 'cpp-error (parse-identifier-list (lex "1")))
+ 'cpp-error (parse-identifier-list (lex "(1)")))
(test-error "Rest args not at end is invalid"
- 'cpp-error (parse-identifier-list (lex "..., y")))))
+ 'cpp-error (parse-identifier-list (lex "(..., y)")))))
@@ -188,6 +197,12 @@
(test-equal '() remaining)
(test-equal 0 nls)))
+ (test-group "Two empty parameters"
+ (let ((containing remaining nls (parse-parameter-list (lex "(,)"))))
+ (test-equal (list (lex "") (lex "")) containing)
+ (test-equal '() remaining)
+ (test-equal 0 nls)))
+
(test-group "Numeric parameter"
(let ((containing remaining nls (parse-parameter-list (lex "(1)"))))
(test-equal (list (lex "1")) containing)
@@ -201,7 +216,13 @@
(test-equal (list (lex "x") (lex " (y, z)"))
containing)
(test-equal '() remaining)
- (test-equal 0 nls))))
+ (test-equal 0 nls)))
+
+ (test-group "Newline in parameters"
+ (let ((containing remaining nls (parse-parameter-list (lex "(\n1\n)"))))
+ (test-equal (list (lex "\n1\n")) containing)
+ (test-equal '() remaining)
+ (test-equal 2 nls))))
(test-group "Build parameter map"
(test-equal "Simplest case, zero arguments"