aboutsummaryrefslogtreecommitdiff
path: root/tests/function/builtin/testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/function/builtin/testscript')
-rw-r--r--tests/function/builtin/testscript32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript
index 3d31ca2..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
@@ -86,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