diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-23 16:53:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-23 16:53:31 +0200 |
commit | e19095ef128f53644bc7650094d8924633c79efa (patch) | |
tree | d039eb841341af2d7b3f544b95644ad1afcb846c /tests/expansion | |
parent | 793f078ec31dc61921b382f14412ed3e25cc51d8 (diff) |
Implement value type propagation on expansion
Currently, we only propagate types of sole, unquoted expansions (variable,
function call, or eval context), similar to NULL. To untypify the value,
simply quote it.
Diffstat (limited to 'tests/expansion')
-rw-r--r-- | tests/expansion/buildfile | 7 | ||||
-rw-r--r-- | tests/expansion/common.test | 11 | ||||
-rw-r--r-- | tests/expansion/type.test | 53 |
3 files changed, 71 insertions, 0 deletions
diff --git a/tests/expansion/buildfile b/tests/expansion/buildfile new file mode 100644 index 0000000..81df59e --- /dev/null +++ b/tests/expansion/buildfile @@ -0,0 +1,7 @@ +# file : tests/expansion/buildfile +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +./: test{type} file{common.test} + +test{*}: test = $effect($build.path) diff --git a/tests/expansion/common.test b/tests/expansion/common.test new file mode 100644 index 0000000..881c74e --- /dev/null +++ b/tests/expansion/common.test @@ -0,0 +1,11 @@ +# file : tests/expansion/assert.test +# 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 diff --git a/tests/expansion/type.test b/tests/expansion/type.test new file mode 100644 index 0000000..1aae5b6 --- /dev/null +++ b/tests/expansion/type.test @@ -0,0 +1,53 @@ +# file : tests/expansion/type.test +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test type propagation during expansion. + +.include common.test + +: var +: +$* <<EOI +x = [bool] true +y = \$x +assert \(\$type\(\$y) == bool) +EOI + +: eval +: +$* <<EOI +y = \([bool] true) +assert \(\$type\(\$y) == bool) +EOI + +: func +: +$* <<EOI +y = \$identity\([bool] true) +assert \(\$type\(\$y) == bool) +EOI + +: untypify +: +$* <<EOI +x = [bool] true +y = "\$x" +assert \(\$type\(\$y) == "") +EOI + +: type-conflict +: +$* <'print [bool] ([string] true)' 2>>EOE != 0 +<stdin>:1:7: error: conflicting attribute type bool and value type string + info: use quoting to untypify the value +EOE + +: retypify +: +$* <'print [bool] "([string] true)"' >'true' + +: retypify-name +: Test the "steal" case of untypify() +: +$* <'print [bool] "([name] true)"' >'true' |