diff options
Diffstat (limited to 'tests/test/cpp/preprocessor2.scm')
-rw-r--r-- | tests/test/cpp/preprocessor2.scm | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/tests/test/cpp/preprocessor2.scm b/tests/test/cpp/preprocessor2.scm index 5e1bb736..b4825907 100644 --- a/tests/test/cpp/preprocessor2.scm +++ b/tests/test/cpp/preprocessor2.scm @@ -592,17 +592,11 @@ (lex "x")))))) +;; TODO ;; resolve-h-file ;; resolve-q-file -;; handle-pragma ;; include -;; if -;; else -;; ifdef -;; ifndef -;; elif - (call-with-values (lambda () @@ -803,13 +797,6 @@ LISTING(..\\listing.dir) " e)))))) )) -;; TODO -;; if -;; else -;; ifdef -;; ifndef -;; elif - (test-group "Next token matches?" (test-assert "Zero tokens never match" (not (next-token-matches? (const #t) '()))) @@ -990,3 +977,64 @@ debug(\"X = %d\\n\", x); showlist(The first, second, and third items.); report(x>y, \"x is %d but y is %d\", x, y); ")))) + + + +(test-group "Conditionals" + (test-group "ifdef" + (test-equal "#ifdef on non-defined" + (lex "") + (run " +#ifdef X +x +#endif")) + + (test-equal "#ifdef on defined" + (lex "x") + (run " +#define X +#ifdef X +x +#endif"))) + + (test-group "ifndef" + (test-equal "#ifndef on non-defined" + (lex "x") + (run " +#ifndef X +x +#endif")) + + (test-equal "#ifndef on defined" + (lex "") + (run " +#define X +#ifndef X +x +#endif +"))) + + (test-group "else" + (test-equal "else from active to inactive" + (lex "1") + (run " +#ifndef X +1 +#else +2 +#endif")) + + (test-equal "else from inactive to active" + (lex "2") + (run " +#ifdef X +1 +#else +2 +#endif"))) + +;; TODO +;; if +;; elif + + ) |