summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2017-01-27 09:48:13 -0600
committerNicolas Williams <nico@cryptonector.com>2017-01-30 14:11:05 -0600
commit396543191cec32f69712b4364d26a0ebaa61b801 (patch)
treed62f2fff5f695e25ef1d219e4958dcefbf58cacc /tests
parente24af3c78e78a3aab05a2800d825d56f1d842b1b (diff)
Make first(g) more efficient: extract only 1 value
first(g) was extracting two values, which, if g is slow, made first(g) slow. And if the second extraction were to throw an error, then first(g) would throw that error, which is clearly not the right thing to do. Besides that, first(g) was allocating garbage, which it no longer does.
Diffstat (limited to 'tests')
-rw-r--r--tests/jq.test5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/jq.test b/tests/jq.test
index fc92d35b..302952d5 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -303,6 +303,11 @@ null
10
[0,9,0,5,"nth doesn't support negative indices"]
+# Check that first(g) does not extract more than one value from g
+first(1,error("foo"))
+null
+1
+
#
# Check that various builtins evalute all arguments where appropriate,
# doing cartesian products where appropriate.