summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-08-10 16:52:03 -0500
committerNicolas Williams <nico@cryptonector.com>2014-08-14 03:26:26 -0500
commit1ba8c2cfa649300becae21876d3613362c219a37 (patch)
tree30ebb15e1bdd56927c09f9d74b573b019a260994 /tests
parentd654724fefab7a24ffa8e718f56028cff32971b9 (diff)
Add `module` directive, `modulemeta` builtin
Fix #425.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run34
1 files changed, 27 insertions, 7 deletions
diff --git a/tests/run b/tests/run
index 878128de..8a4ef0e7 100755
--- a/tests/run
+++ b/tests/run
@@ -71,6 +71,12 @@ if [ $n -ne 5 ]; then
exit 1
fi
+v=`scripts/version`
+case "$v" in
+*-*) v=next;;
+*) true;;
+esac
+
## Test library/module system
cat > "$d/.jq" <<EOF
@@ -81,22 +87,31 @@ def g: "bar";
def fg: f+g;
EOF
-cat > "$d/a.jq" <<EOF
+mkdir -p "$d/$v/b" "$d/any/c" "$d/any/syntaxerror"
+
+cat > "$d/$v/a.jq" <<EOF
+module a {version:1.7};
def a: "a";
EOF
-cat > "$d/b.jq" <<EOF
+cat > "$d/$v/b/b.jq" <<EOF
def a: "b";
def b: "c";
EOF
-cat > "$d/c.jq" <<EOF
+cat > "$d/any/c/d.jq" <<EOF
+def meh: "meh";
+EOF
+
+cat > "$d/any/c/c.jq" <<"EOF"
+module c {whatever:null};
import a as foo;
+import d as d {search:"$ORIGIN/"};
def a: 0;
-def c: foo::a + "c";
+def c: foo::a + "c" + d::meh;
EOF
-cat > "$d/syntaxerror.jq" <<EOF
+cat > "$d/any/syntaxerror/syntaxerror.jq" <<EOF
wat;
EOF
@@ -110,16 +125,21 @@ if [ `HOME=$d $VALGRIND $Q ./jq --debug-dump-disasm -n fg | grep '^[a-z]' | wc -
exit 1
fi
-if ! $VALGRIND $Q ./jq -ner -L $d 'import a as foo; import b as bar; import a as foobar; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a, foobar::a] | . == ["a","b","c","a","a"]' > /dev/null; then
+if ! $VALGRIND $Q ./jq -ner -L $d 'import a as foo; import b as bar; import a; def fooa: foo::a; [fooa, bar::a, bar::b, foo::a, a] | . == ["a","b","c","a","a"]' > /dev/null; then
echo "Module system appears to be broken" 1>&2
exit 1
fi
-if ! $VALGRIND $Q ./jq -ner -L $d 'import c as foo; [foo::a, foo::c] | . == [0,"ac"]' > /dev/null; then
+if ! $VALGRIND $Q ./jq -ner -L $d 'import c as foo; [foo::a, foo::c] | . == [0,"acmeh"]' > /dev/null; then
echo "Module system appears to be broken" 1>&2
exit 1
fi
+if [ "`$VALGRIND $Q ./jq -cner -L $d '\"c\" | modulemeta'`" != '{"whatever":null,"name":"c","deps":[{"as":"foo","name":"a"},{"search":"$ORIGIN/","as":"d","name":"d"}]}' ]; then
+ echo "modulemeta builtin appears to be broken" 1>&2
+ exit 1
+fi
+
if $VALGRIND ./jq -ner -L $d 'import syntaxerror; .' > $d/out 2>&1; then
echo "Module system appears to be broken" 1>&2
exit 1