From f743e08220883eef86effdac8a5e7c94deddc302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 11 Jul 2022 19:48:47 +0200 Subject: Cleanup + fix __LINE__. --- tests/test/cpp/cpp-environment.scm | 4 +++- tests/test/cpp/preprocessor2.scm | 44 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/test/cpp/cpp-environment.scm b/tests/test/cpp/cpp-environment.scm index d31ec208..df4736fb 100644 --- a/tests/test/cpp/cpp-environment.scm +++ b/tests/test/cpp/cpp-environment.scm @@ -16,7 +16,9 @@ (define cpp-file-stack (@@ (c cpp-environment) cpp-file-stack)) (let ((e (make-environment))) - (test-equal "Default file stack" '(("*outside*" . 1)) (cpp-file-stack e)) + (test-equal "Default file stack" + '(("*outside*" . 1)) + (cpp-file-stack e)) (let ((e* (enter-file e "test.c"))) (test-equal "File stack after entering file" '(("test.c" . 1) ("*outside*" . 1)) (cpp-file-stack e*)) diff --git a/tests/test/cpp/preprocessor2.scm b/tests/test/cpp/preprocessor2.scm index 9ad1a726..b5e9e001 100644 --- a/tests/test/cpp/preprocessor2.scm +++ b/tests/test/cpp/preprocessor2.scm @@ -14,10 +14,6 @@ :use-module (c lex2)) -(test-skip "__LINE__ through macro") -(test-skip "__LINE__ standalone") - - ;; arbitrary tokens useful in tests for checking that values are returned correctly (define before (car (lex "before"))) (define after (car (lex "after"))) @@ -599,36 +595,45 @@ f(10) (handle-preprocessing-tokens (make-environment) (lex "1"))) +(define (run str) + (remove-noexpand + (handle-preprocessing-tokens + (make-environment) + (tokenize str)))) + + (test-equal "Define" (lex "1") - (remove-noexpand - (handle-preprocessing-tokens (make-environment) - (lex " + (run " #define x 1 -x")))) +x")) + +(test-equal "only __LINE__" + (lex "1") + (run "__LINE__")) + +(test-equal "__LINE__ after linebreak" + (lex "2") + (run "\n__LINE__")) + (test-equal "__LINE__ through macro" (lex "5") - (drop-whitespace-both - (remove-noexpand - (handle-preprocessing-tokens (make-environment) - (tokenize " // 1 + (drop-whitespace-both (run " // 1 #define x __LINE__ // 2 // 3 // 4 x // 5")) - ))) + ) (test-equal "__LINE__ standalone" (lex "5") (drop-whitespace-both - (remove-noexpand - (handle-preprocessing-tokens (make-environment) - (tokenize " // 1 + (run " // 1 // 2 // 3 // 4 -__LINE__"))))) +__LINE__"))) @@ -641,11 +646,6 @@ __LINE__"))))) (test-equal (lex "ab") (expand## (lex "a ## b"))) ) -(define (run str) - (remove-noexpand - (handle-preprocessing-tokens - (make-environment) - (tokenize str)))) (test-equal "Token concatenation in function like macro" -- cgit v1.2.3