aboutsummaryrefslogtreecommitdiff
path: root/tests/function/builtin/testscript
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-23 14:58:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-23 14:58:30 +0200
commit79cb3221c2babe6f560f2e3e463e899631a32b33 (patch)
tree2135159931dde6acde213d6e8de1bdbd06d222d4 /tests/function/builtin/testscript
parentc6265603e0e98c19f8d81c8edd5a34a550063c02 (diff)
Implement few builtin functions that can operate on any value
type() null() empty () identity()
Diffstat (limited to 'tests/function/builtin/testscript')
-rw-r--r--tests/function/builtin/testscript68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript
new file mode 100644
index 0000000..1a4c5d1
--- /dev/null
+++ b/tests/function/builtin/testscript
@@ -0,0 +1,68 @@
+# file : tests/function/path/testscript
+# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
++mkdir build
++cat <<EOI >>>build/bootstrap.build
+project = test
+amalgamation =
+EOI
+
+test.options += -q --buildfile - noop
+
+: type
+:
+{
+ $* <'print $type([string])' >'string' : empty-typed
+ $* <'print $type("")' >'' : empty-untyped
+
+ $* <'print $type([string null])' >'string' : null-typed
+ $* <'print $type([null])' >'' : null-untyped
+
+ $* <'print $type([string] abc)' >'string' : value-typed
+ $* <'print $type(abc)' >'' : value-untyped
+}
+
+: null
+:
+{
+ $* <'print $null("")' >'false' : empty
+ $* <'print $null(abc)' >'false' : value
+ $* <'print $null([null])' >'true' : null
+}
+
+: empty
+:
+{
+ $* <<EOI >'true' : empty-untyped
+ x =
+ print \$empty\(\$x)
+ EOI
+
+ $* <'print $empty([string])' >'true' : empty-typed
+ $* <'print $empty(abc)' >'false' : name
+ $* <'print $empty(abc cxx{foo})' >'false' : names
+ $* <'print $empty([bool] false)' >'false' : bool
+}
+
+: identity
+:
+{
+ $* <'print $identity([string])' >'';
+ $* <'print $type($identity([string]))' >'string' : empty-typed
+
+ $* <'print $identity("")' >'{}';
+ $* <'print $type($identity(""))' >'' : empty-untyped
+
+ $* <'print $identity([string null])' >'[null]';
+ $* <'print $type($identity([string null]))' >'string' : null-typed
+
+ $* <'print $identity([null])' >'[null]';
+ $* <'print $type($identity([null]))' >'' : null-untyped
+
+ $* <'print $identity([string] abc)' >'abc';
+ $* <'print $type($identity([string] abc))' >'string' : null-typed
+
+ $* <'print $identity(abc)' >'abc';
+ $* <'print $type($identity(abc))' >'' : null-untyped
+}