aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-25 21:56:29 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-25 21:56:29 -0700
commita3e288ab5be1008dafa86b47c18ebf480cc9d6a7 (patch)
treeadd4bab3f4caf9cf5e6d8c01ccc12f2283c5bdcd /test/run_tests.cpp
parent1d68150242c9304ac7f35a3d827c3c6e5aeea521 (diff)
downloadzig-a3e288ab5be1008dafa86b47c18ebf480cc9d6a7.tar.gz
zig-a3e288ab5be1008dafa86b47c18ebf480cc9d6a7.zip
implement compile time string concatenation
See #76
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 22c8a3b68b..a25134007f 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1279,6 +1279,13 @@ pub fn main(args: [][]u8) -> %void {
%%stdout.printf("OK\n");
}
)SOURCE", "OK\n");
+
+ add_simple_case("string concatenation", R"SOURCE(
+import "std.zig";
+pub fn main(args: [][]u8) -> %void {
+ %%stdout.printf("OK" ++ " IT " ++ "WORKED\n");
+}
+ )SOURCE", "OK IT WORKED\n");
}
@@ -1645,6 +1652,12 @@ extern {
const x = foo();
)SOURCE", 1, ".tmp_source.zig:5:11: error: global variable initializer requires constant expression");
+ add_compile_fail_case("non compile time string concatenation", R"SOURCE(
+fn f(s: []u8) -> []u8 {
+ s ++ "foo"
+}
+ )SOURCE", 1, ".tmp_source.zig:3:5: error: string concatenation requires constant expression");
+
}
static void print_compiler_invocation(TestCase *test_case) {