diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-11 01:10:19 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-11 01:10:19 +0200 |
commit | 35b7888c9b5f217dd2911c0ba93519df36e97922 (patch) | |
tree | e8f8945d7bcc65b146006763eda1097e20f8cc4c /tests/test/cpp | |
parent | Fix #line (diff) | |
download | calp-35b7888c9b5f217dd2911c0ba93519df36e97922.tar.gz calp-35b7888c9b5f217dd2911c0ba93519df36e97922.tar.xz |
Rewrite handel-preprocessing-tokens.
Diffstat (limited to 'tests/test/cpp')
-rw-r--r-- | tests/test/cpp/preprocessor2.scm | 49 |
1 files changed, 49 insertions, 0 deletions
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 |