]> granicus.if.org Git - jq/commitdiff
Test starts/endswith and string multiplication
authorNicolas Williams <nico@cryptonector.com>
Fri, 29 Nov 2013 21:51:51 +0000 (15:51 -0600)
committerNicolas Williams <nico@cryptonector.com>
Thu, 5 Dec 2013 00:21:39 +0000 (18:21 -0600)
tests/all.test

index f8019972622aa6ab2a5fed997d260073bd39fc44..d6231ee822b5c64e58440731afd3842145752eec 100644 (file)
@@ -574,6 +574,19 @@ def inc(x): x |= .+1; inc(.[].a)
 {}
 [true, true, false]
 
+# string operations
+[.[]|startswith("foo")]
+["fo", "foo", "barfoo", "foobar", "barfoob"]
+[false, true, false, true, false]
+
+[.[]|endswith("foo")]
+["fo", "foo", "barfoo", "foobar", "barfoob"]
+[false, true, true, false, false]
+
+[.[] * 3]
+["a", "ab", "abc"]
+["aaa", "ababab", "abcabcabc"]
+
 map(.[1] as $needle | .[0] | contains($needle))
 [[[],[]], [[1,2,3], [1,2]], [[1,2,3], [3,1]], [[1,2,3], [4]], [[1,2,3], [1,4]]]
 [true, true, true, false, false]