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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# -*-perl-*-
$description = 'Test the $(guile ...) function.';
$details = 'This only works on systems that support it.';
# If this instance of make doesn't support GNU Guile, skip it
exists $FEATURES{guile} or return -1;
# Verify simple data type conversions
# Currently we don't support vectors:
# echo '$(guile (vector 1 2 3))'; \
run_make_test(q!
x:;@echo '$(guile #f)'; \
echo '$(guile #t)'; \
echo '$(guile #\c)'; \
echo '$(guile 1234)'; \
echo '$(guile 'foo)'; \
echo '$(guile "bar")'; \
echo '$(guile (cons 'a 'b))'; \
echo '$(guile '(a b (c . d) 1 (2) 3))'
!,
'', "\n#t\nc\n1234\nfoo\nbar\na b\na b c d 1 2 3");
# Verify the gmk-expand function
run_make_test(q!
VAR = $(guile (gmk-expand "$(shell echo hi)"))
x:;@echo '$(VAR)'
!,
'', "hi");
# Verify the gmk-eval function
run_make_test(q!
$(guile (gmk-eval "VAR = hi $(shell echo there)"))
x:;@echo '$(VAR)'
!,
'', "hi there");
# Verify the gmk-eval function with a list
run_make_test(q!
$(guile (gmk-eval '(VAR = 1 (2) () 3)))
x:;@echo '$(VAR)'
!,
'', "1 2 3");
# Verify the gmk-var function
run_make_test(q!
VALUE = hi $(shell echo there)
VAR = $(guile (gmk-var "VALUE"))
x:;@echo '$(VAR)'
!,
'', "hi there");
# Verify the gmk-var function with a symbol
run_make_test(q!
VALUE = hi $(shell echo there)
VAR = $(guile (gmk-var 'VALUE))
x:;@echo '$(VAR)'
!,
'', "hi there");
# Write a Guile program using define and run it
run_make_test(q!
# Define the "fib" function in Guile
define fib
;; A procedure for counting the n:th Fibonacci number
;; See SICP, p. 37
(define (fib n)
(cond ((= n 0) 0)
((= n 1) 1)
(else (+ (fib (- n 1))
(fib (- n 2))))))
endef
$(guile $(fib))
# Now run it
x:;@echo $(guile (fib $(FIB)))
!,
'FIB=10', "55");
1;
|