diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-07 18:40:27 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-07 21:31:32 +0200 |
commit | 1393ce3878e5d14214631fb83d58c819a7849b18 (patch) | |
tree | d1e34b2b459ea9c1702ac72f6e66f0b05ce45223 /tests/test/cpp/cpp-environment.scm | |
parent | Change makefile to explicit list of files. (diff) | |
download | calp-1393ce3878e5d14214631fb83d58c819a7849b18.tar.gz calp-1393ce3878e5d14214631fb83d58c819a7849b18.tar.xz |
work.
Diffstat (limited to 'tests/test/cpp/cpp-environment.scm')
-rw-r--r-- | tests/test/cpp/cpp-environment.scm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test/cpp/cpp-environment.scm b/tests/test/cpp/cpp-environment.scm new file mode 100644 index 00000000..8600c731 --- /dev/null +++ b/tests/test/cpp/cpp-environment.scm @@ -0,0 +1,44 @@ +(define-module (test cpp cpp-environmunt) + :use-module (srfi srfi-64) + :use-module (srfi srfi-88) + :use-module (c cpp-environment) + :use-module (c cpp-environment object-like-macro) + ) + +(let ((e (make-environment))) + (test-equal '(outside) (cpp-if-status e)) + (let ((e* (enter-active-if e))) + (test-equal "Enter works" '(active-if outside) (cpp-if-status e*)) + (test-equal "Original object remainins unmodified" + '(outside) (cpp-if-status e)))) + +(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)) + (let ((e* (enter-file e "test.c"))) + (test-equal "File stack after entering file" + '(("test.c" . 1) ("*outside*" . 1)) (cpp-file-stack e*)) + (let ((e** (bump-line e*))) + (test-equal 2 (current-line e**))))) + + + +(let ((e (make-environment))) + (let ((e* (add-identifier! + e "key" + (object-like-macro + identifier: "key" + body: '((preprocessing-token (identifier "value"))))))) + (let ((result (get-identifier e* "key"))) + (test-assert (macro? result)) + (test-equal '((preprocessing-token (identifier "value"))) + (macro-body result)))) + ;; (get-identifier e "key") here is undefined + ) + +(let ((e (make-environment))) + (let ((result (get-identifier e "key"))) + (test-assert "Missing identifier returns #f" + (not result))) + ) |