From 35b7888c9b5f217dd2911c0ba93519df36e97922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 11 Jul 2022 01:10:19 +0200 Subject: Rewrite handel-preprocessing-tokens. --- tests/test/cpp/preprocessor2.scm | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests/test/cpp/preprocessor2.scm') diff --git a/tests/test/cpp/preprocessor2.scm b/tests/test/cpp/preprocessor2.scm index 9e11bb04..cbc62edd 100644 --- a/tests/test/cpp/preprocessor2.scm +++ b/tests/test/cpp/preprocessor2.scm @@ -10,6 +10,7 @@ :use-module (c cpp-environment) :use-module (c cpp-environment function-like-macro) :use-module (c cpp-environment object-like-macro) + :use-module ((c cpp-util) :select (drop-whitespace-both)) :use-module (c lex2)) @@ -568,3 +569,51 @@ f(10) ;; resolve-h-file ;; resolve-q-file ;; handle-pragma +;; include + +;; if +;; else +;; ifdef +;; ifndef +;; elif + + +(define handle-preprocessing-tokens (@@ (c preprocessor2) handle-preprocessing-tokens)) + +(define tokenize (@@ (c preprocessor2) tokenize)) + +(test-equal "Simplest case" (lex "1") + (handle-preprocessing-tokens (make-environment) + (lex "1"))) + +(test-equal "Define" + (lex "1") + (remove-noexpand + (handle-preprocessing-tokens (make-environment) + (lex " +#define x 1 +x")))) + +(test-equal "__LINE__" + (lex "5") + (drop-whitespace-both + (remove-noexpand + (handle-preprocessing-tokens (make-environment) + (tokenize " // 1 +#define x __LINE__ // 2 +// 3 +// 4 +x // 5")) + ))) + +;; __LINE__ +;; #line +;; #undef +;; #error +;; #pragma + +;; if +;; else +;; ifdef +;; ifndef +;; elif -- cgit v1.2.3