summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-01-26 21:49:17 +0100
committerLudovic Courtès <ludo@gnu.org>2013-01-26 21:49:17 +0100
commit13ff681c33a0ff6ff6004d44126697f6dea3ec73 (patch)
treeccfa1238cc7d154e9aefd20591978e1cf07f933f
parented7c4a5d777bcff78512f1f1f9f2847ade90af11 (diff)
downloadguile-13ff681c33a0ff6ff6004d44126697f6dea3ec73.tar.gz
Add tests for `--language'.
* test-suite/standalone/Makefile.am (top_srcdir): Add `top_srcdir'. (check_SCRIPTS, TESTS): Add `test-language'. (EXTRA_DIST): Add `test-language.el' and `test-language.js'. * test-suite/standalone/test-language, test-suite/standalone/test-language.el, test-suite/standalone/test-language.js: New files.
-rw-r--r--test-suite/standalone/Makefile.am7
-rwxr-xr-xtest-suite/standalone/test-language25
-rw-r--r--test-suite/standalone/test-language.el11
-rw-r--r--test-suite/standalone/test-language.js12
4 files changed, 54 insertions, 1 deletions
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index daa3d0744..be5d91380 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in.
##
## Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-## 2011, 2012 Free Software Foundation, Inc.
+## 2011, 2012, 2013 Free Software Foundation, Inc.
##
## This file is part of GUILE.
##
@@ -31,6 +31,7 @@ BUILT_SOURCES =
EXTRA_DIST =
TESTS_ENVIRONMENT = \
+ top_srcdir="$(top_srcdir)" \
srcdir="$(srcdir)" \
builddir="$(builddir)" \
@LOCALCHARSET_TESTS_ENVIRONMENT@ \
@@ -88,6 +89,10 @@ TESTS += test-command-line-encoding
check_SCRIPTS += test-command-line-encoding2
TESTS += test-command-line-encoding2
+check_SCRIPTS += test-language
+TESTS += test-language
+EXTRA_DIST += test-language.el test-language.js
+
# test-num2integral
test_num2integral_SOURCES = test-num2integral.c
test_num2integral_CFLAGS = ${test_cflags}
diff --git a/test-suite/standalone/test-language b/test-suite/standalone/test-language
new file mode 100755
index 000000000..59ed82b62
--- /dev/null
+++ b/test-suite/standalone/test-language
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+
+# Make sure that code passed as `-c' or `-l' is evaluted using the
+# right language.
+
+# The default language in effect until `--language' is encountered is
+# Scheme.
+guile -c "(exit (= 3 (apply + '(1 2))))" --language=elisp
+! guile -c "(= (funcall (symbol-function '+) 1 2) 3)" 2> /dev/null
+
+guile --language=elisp -c "(= (funcall (symbol-function '+) 1 2) 3)"
+guile --language=ecmascript -c '(function (x) { return x * x; })(2);'
+
+# Same with `-l'.
+guile --no-auto-compile -l "$top_srcdir/module/ice-9/q.scm" -c 1
+guile --no-auto-compile \
+ -l "$top_srcdir/module/ice-9/q.scm" \
+ --language=elisp \
+ -l "$srcdir/test-language.el" \
+ --language=ecmascript \
+ -l "$srcdir/test-language.js" \
+ --language=scheme \
+ -c 1
diff --git a/test-suite/standalone/test-language.el b/test-suite/standalone/test-language.el
new file mode 100644
index 000000000..c1f09cc3f
--- /dev/null
+++ b/test-suite/standalone/test-language.el
@@ -0,0 +1,11 @@
+;; Sample Elisp code for `test-language'.
+
+(defun fib (n)
+ "Anything but a fib."
+ (if (<= n 1)
+ n
+ (+ (fib (- n 1))
+ (fib (- n 2)))))
+
+(or (= 13 (fib 7))
+ (error "Something's wrong!"))
diff --git a/test-suite/standalone/test-language.js b/test-suite/standalone/test-language.js
new file mode 100644
index 000000000..c8de366cc
--- /dev/null
+++ b/test-suite/standalone/test-language.js
@@ -0,0 +1,12 @@
+/* Sample ECMAscript code for `test-language'. */
+
+function fib (n)
+{
+ if (n <= 1)
+ return n;
+ else
+ return fib (n - 1) + fib (n - 2);
+}
+
+if (fib (7) != 13)
+ error ("Something's wrong!");