From c992c4d80f51540699f33fed067caf6b7c38df79 Mon Sep 17 00:00:00 2001
From: Paul Smith <psmith@gnu.org>
Date: Sun, 15 Jan 2012 22:41:53 +0000
Subject: Add GNU Guile as an optional embedded scripting language for make.

On configure-enabled systems, configure will detect Guile installed
(using pkg-config, which is how GNU Guile is distributed) and enable
it if so.

On all non-configure-enabled systems, currently, the default is for
Guile support to be disabled.
---
 tests/scripts/functions/guile | 81 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 tests/scripts/functions/guile

(limited to 'tests/scripts/functions')

diff --git a/tests/scripts/functions/guile b/tests/scripts/functions/guile
new file mode 100644
index 0000000..82c02bc
--- /dev/null
+++ b/tests/scripts/functions/guile
@@ -0,0 +1,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;
-- 
cgit v1.2.3