From 0e486cd3642da8a442629ffce9a3daf16745c35e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 2 Apr 2016 16:18:43 +0200 Subject: Implement variable typing (via attributes) Now we can do: [string] str = foo --- tests/variable/type/buildfile | 21 +++++++++++++++++++++ tests/variable/type/test.out | 2 ++ tests/variable/type/test.sh | 3 +++ 3 files changed, 26 insertions(+) create mode 100644 tests/variable/type/buildfile create mode 100644 tests/variable/type/test.out create mode 100755 tests/variable/type/test.sh (limited to 'tests') diff --git a/tests/variable/type/buildfile b/tests/variable/type/buildfile new file mode 100644 index 0000000..372b0ad --- /dev/null +++ b/tests/variable/type/buildfile @@ -0,0 +1,21 @@ +# Variable typing. +# +[string] str1 = bar +str1 =+ foo +str1 += baz +print $str1 + +str2 = bar +[string] str2 =+ foo +str2 += baz +print $str2 + +#[string] str3 = foo +#[bool] str3 = false # error: changing str3 type from string to bool + +#[bool string] str3 = foo # error: multiple variable types: bool, string + +#[junk] jnk = foo # error: unknown variable attribute junk + + +./: diff --git a/tests/variable/type/test.out b/tests/variable/type/test.out new file mode 100644 index 0000000..f5dfb84 --- /dev/null +++ b/tests/variable/type/test.out @@ -0,0 +1,2 @@ +foobarbaz +foobarbaz diff --git a/tests/variable/type/test.sh b/tests/variable/type/test.sh new file mode 100755 index 0000000..afcb3bd --- /dev/null +++ b/tests/variable/type/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +b -q | diff -u test.out - -- cgit v1.1