From 473ee634ea07e988b7074e5b323e02d72e9c9c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 16 Jul 2022 23:44:52 +0200 Subject: Cleanup in preprocessor2. --- tests/test/cpp/preprocessor2.scm | 45 +++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'tests/test/cpp') 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" -- cgit v1.2.3