aboutsummaryrefslogtreecommitdiff
path: root/tests/function/builtin/testscript
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-02 10:18:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-02 10:18:50 +0200
commit1c6096e53a906d7821a401d91b32ca02df3d715f (patch)
tree380d7d9acc6fc186c7c7d18da025613e71526c71 /tests/function/builtin/testscript
parent2a09b60a4169c151fa89e1d4c979a4b5c40a0252 (diff)
Add $first()/$second() pair functions
Diffstat (limited to 'tests/function/builtin/testscript')
-rw-r--r--tests/function/builtin/testscript25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript
index 714a38d..88f802a 100644
--- a/tests/function/builtin/testscript
+++ b/tests/function/builtin/testscript
@@ -55,6 +55,31 @@
$* <'print $empty([bool] false)' >'false' : bool
}
+: 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
:
{