blob: 8600c7315f4faa4f4c9b9a7fd959c7690b454a1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)))
)
|