diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-23 14:58:30 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-23 14:58:30 +0200 |
commit | 79cb3221c2babe6f560f2e3e463e899631a32b33 (patch) | |
tree | 2135159931dde6acde213d6e8de1bdbd06d222d4 /tests | |
parent | c6265603e0e98c19f8d81c8edd5a34a550063c02 (diff) |
Implement few builtin functions that can operate on any value
type()
null()
empty ()
identity()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/function/buildfile | 2 | ||||
-rw-r--r-- | tests/function/builtin/buildfile | 7 | ||||
-rw-r--r-- | tests/function/builtin/testscript | 68 |
3 files changed, 76 insertions, 1 deletions
diff --git a/tests/function/buildfile b/tests/function/buildfile index 52288ca..6c26737 100644 --- a/tests/function/buildfile +++ b/tests/function/buildfile @@ -2,6 +2,6 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -d = path/ +d = builtin/ path/ ./: $d include $d diff --git a/tests/function/builtin/buildfile b/tests/function/builtin/buildfile new file mode 100644 index 0000000..5a49ad0 --- /dev/null +++ b/tests/function/builtin/buildfile @@ -0,0 +1,7 @@ +# file : tests/function/builtin/buildfile +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +./: test{testscript} + +test{*}: test = $effect($build.path) 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 +} |