From a3e288ab5be1008dafa86b47c18ebf480cc9d6a7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Jan 2016 21:56:29 -0700 Subject: implement compile time string concatenation See #76 --- test/run_tests.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/run_tests.cpp') 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) { -- cgit v1.2.3