From e19095ef128f53644bc7650094d8924633c79efa Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2016 16:53:31 +0200 Subject: 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. --- tests/buildfile | 2 +- tests/expansion/buildfile | 7 +++++ tests/expansion/common.test | 11 ++++++++ tests/expansion/type.test | 53 ++++++++++++++++++++++++++++++++++++ tests/test/script/builtin/touch.test | 2 +- tests/variable/dir-path/buildfile | 6 ++-- 6 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 tests/expansion/buildfile create mode 100644 tests/expansion/common.test create mode 100644 tests/expansion/type.test (limited to 'tests') diff --git a/tests/buildfile b/tests/buildfile index f38b3ca..405df8f 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -2,6 +2,6 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -d = directive/ function/ test/ +d = directive/ expansion/ function/ test/ ./: $d include $d 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 <>>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 +: +$* <>EOE != 0 +: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' diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index 4d2ff57..ef950ea 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -39,7 +39,7 @@ touch '' 2>"touch: invalid path ''" == 1 : : Test touching an existing directory. : -a = [path] $~; +a = $~; a += "a"; mkdir a; touch 2>"touch: '$a' exists and is not a file" a == 1 diff --git a/tests/variable/dir-path/buildfile b/tests/variable/dir-path/buildfile index 5c99f07..c6fdb46 100644 --- a/tests/variable/dir-path/buildfile +++ b/tests/variable/dir-path/buildfile @@ -27,7 +27,7 @@ print [strings] -I $y print -I $y/baz print -z = [strings] $x # Re-typed. +z = [strings] "$x" # Re-typed. print $z print @@ -37,9 +37,9 @@ r = [dir_path] / print $r/foo r += foo -print [strings] $r +print [strings] "$r" r += bar -print [strings] $r +print [strings] "$r" ./: -- cgit v1.1