aboutsummaryrefslogtreecommitdiff
path: root/tests/expansion
diff options
context:
space:
mode:
Diffstat (limited to 'tests/expansion')
-rw-r--r--tests/expansion/buildfile7
-rw-r--r--tests/expansion/common.test11
-rw-r--r--tests/expansion/type.test53
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'