diff options
Diffstat (limited to 'tests/function/builtin')
-rw-r--r-- | tests/function/builtin/testscript | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript index 00d594b..04e8bd8 100644 --- a/tests/function/builtin/testscript +++ b/tests/function/builtin/testscript @@ -53,6 +53,34 @@ $* <'print $empty(abc)' >'false' : name $* <'print $empty(abc cxx{foo})' >'false' : names $* <'print $empty([bool] false)' >'false' : bool + $* <'print $empty([json] null)' >'true' : json-null + $* <'print $empty([json] "[]")' >'true' : json-array + $* <'print $empty([json] "{}")' >'true' : json-object +} + +: first-second +: +{ + $* <'print $first(a@1)' >'a' : first + $* <'print $second(a@1)' >'1' : second + + $* <'print $first(@1)' >'{}' : first-empty + $* <'print $second(a@)' >'{}' : second-empty + + $* <'print $first(1)' >'[null]' : first-null + $* <'print $second(a)' >'[null]' : second-null + + $* <'print $first(1, true)' >'1' : first-all + $* <'print $second(a, true)' >'a' : second-all + + $* <'print $first(0 a@1 b@2 c@ 4)' >'a b c' : firsts + $* <'print $second(z a@1 b@2 @3 d)' >'1 2 3' : seconds + + $* <'print $first(0 a@1 b@2 c@ 4, true)' >'0 a b c 4' : firsts-all + $* <'print $second(z a@1 b@2 @3 d, true)' >'z 1 2 3 d' : seconds-all + + $* <'print $first([name_pair] a@1)' >'a' : first-typed + $* <'print $second([name_pair] a@1)' >'1' : second-typed } : identity @@ -77,13 +105,6 @@ $* <'print $type($identity(abc))' >'' : untyped } -: sort -: -{ - $* <'print $sort([uint64s] 0 2 1 000)' >'0 0 1 2' : basics - $* <'print $sort([uint64s] 0 2 1 000, dedup)' >'0 1 2' : dedup -} - : getenv : { @@ -93,8 +114,8 @@ : likely is set at the time of login, and on Windows it is set by build2 on : startup. : - : @@ Use a custom variable, when an ability to set environment variables in - : testscript is implemented. + : @@ TMP Use a custom variable, when an ability to set environment variables + : in testscript is implemented. It is now! : { : string |