summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMuh Muhten <muh.muhten@gmail.com>2019-02-20 23:05:29 -0500
committerNico Williams <nico@cryptonector.com>2019-02-26 21:57:08 -0600
commitabed751e9669ee716b04a8923413c4bc2734185d (patch)
treebb8740582ffe3e221c0a103390bcd15614fa2efd /tests
parent141bb78e967f0d088b9fda134bb75e23405bd844 (diff)
Bind libraries backward for consistent shadowing
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test20
-rw-r--r--tests/modules/shadow1.jq2
-rw-r--r--tests/modules/shadow2.jq1
-rw-r--r--tests/modules/test_bind_order0.jq1
-rw-r--r--tests/modules/test_bind_order1.jq2
-rw-r--r--tests/modules/test_bind_order2.jq1
6 files changed, 25 insertions, 2 deletions
diff --git a/tests/jq.test b/tests/jq.test
index 28b325f9..f75039c7 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -604,6 +604,10 @@ def f(a;b;c;d;e;f): [a+1,b,c,d,e,f]; f(.[0];.[1];.[0];.[0];.[0];.[0])
[1,2]
[2,2,1,1,1,1]
+def f: 1; def g: f, def f: 2; def g: 3; f, def f: g; f, g; def f: 4; [f, def f: g; def g: 5; f, g]+[f,g]
+null
+[4,1,2,3,3,5,4,1,2,3,3]
+
# Test precedence of 'def' vs '|'
def a: 0; . | a
null
@@ -1464,6 +1468,18 @@ import "data" as $e; import "data" as $d; [$d[].this,$e[].that,$d::d[].this,$e::
null
"is a test;is too;is a test;is too"
+include "shadow1"; e
+null
+2
+
+include "shadow1"; include "shadow2"; e
+null
+3
+
+import "shadow1" as f; import "shadow2" as f; import "shadow1" as e; [e::e, f::e]
+null
+[2,3]
+
%%FAIL
module (.+1); 0
jq: error: Module metadata must be constant at <top-level>, line 1:
@@ -1488,6 +1504,10 @@ modulemeta
"c"
{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}]}
+modulemeta | .deps |= length
+"c"
+{"whatever":null,"deps":6}
+
%%FAIL IGNORE MSG
import "syntaxerror" as e; .
jq: error: syntax error, unexpected ';', expecting $end (Unix shell quoting issues?) at /home/nico/ws/jq/tests/modules/syntaxerror/syntaxerror.jq, line 1:
diff --git a/tests/modules/shadow1.jq b/tests/modules/shadow1.jq
new file mode 100644
index 00000000..47c31eb0
--- /dev/null
+++ b/tests/modules/shadow1.jq
@@ -0,0 +1,2 @@
+def e: 1;
+def e: 2;
diff --git a/tests/modules/shadow2.jq b/tests/modules/shadow2.jq
new file mode 100644
index 00000000..61b7c007
--- /dev/null
+++ b/tests/modules/shadow2.jq
@@ -0,0 +1 @@
+def e: 3;
diff --git a/tests/modules/test_bind_order0.jq b/tests/modules/test_bind_order0.jq
index 8cb49a99..c2fc0f00 100644
--- a/tests/modules/test_bind_order0.jq
+++ b/tests/modules/test_bind_order0.jq
@@ -1 +1,2 @@
def sym0: 0;
+def sym1: 0;
diff --git a/tests/modules/test_bind_order1.jq b/tests/modules/test_bind_order1.jq
index be72b43c..0d103440 100644
--- a/tests/modules/test_bind_order1.jq
+++ b/tests/modules/test_bind_order1.jq
@@ -1,2 +1,2 @@
-def sym0: 1;
def sym1: 1;
+def sym2: 1;
diff --git a/tests/modules/test_bind_order2.jq b/tests/modules/test_bind_order2.jq
index 86f422bf..8647c514 100644
--- a/tests/modules/test_bind_order2.jq
+++ b/tests/modules/test_bind_order2.jq
@@ -1,2 +1 @@
-def sym1: 2;
def sym2: 2;