diff options
author | Nicolas Williams <nico@cryptonector.com> | 2014-08-10 16:52:03 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-08-14 03:26:26 -0500 |
commit | 1ba8c2cfa649300becae21876d3613362c219a37 (patch) | |
tree | 30ebb15e1bdd56927c09f9d74b573b019a260994 /tests | |
parent | d654724fefab7a24ffa8e718f56028cff32971b9 (diff) |
Add `module` directive, `modulemeta` builtin
Fix #425.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/run | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -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 |