Commit 832454f38b

Andrew Kelley <superjoe30@gmail.com>
2016-04-18 22:06:17
move 2 tests to self hosted land
1 parent c899368
Changed files (2)
test/run_tests.cpp
@@ -430,33 +430,6 @@ pub fn main(args: [][]u8) -> %void {
 }
     )SOURCE", "9\n8\n7\n6\n0\n1\n2\n3\n9\n8\n7\n6\n0\n1\n2\n3\n");
 
-    add_simple_case("pointer to void return type", R"SOURCE(
-const io = @import("std").io;
-const x = void{};
-fn f() -> &void {
-    %%io.stdout.printf("OK\n");
-    return &x;
-}
-pub fn main(args: [][]u8) -> %void {
-    const a = f();
-    return *a;
-}
-    )SOURCE", "OK\n");
-
-    add_simple_case("call result of if else expression", R"SOURCE(
-const io = @import("std").io;
-fn a() -> []u8 { "a\n" }
-fn b() -> []u8 { "b\n" }
-fn f(x: bool) {
-    %%io.stdout.printf((if (x) a else b)());
-}
-pub fn main(args: [][]u8) -> %void {
-    f(true);
-    f(false);
-}
-    )SOURCE", "a\nb\n");
-
-
     add_simple_case_libc("expose function pointer to C land", R"SOURCE(
 const c = @c_import(@c_include("stdlib.h"));
 
@@ -502,18 +475,6 @@ export fn main(argc: c_int, argv: &&u8) -> c_int {
     )SOURCE", "3.25\n3\n3.00\n-0.40\n");
 
 
-    add_simple_case("const expression eval handling of variables", R"SOURCE(
-const io = @import("std").io;
-pub fn main(args: [][]u8) -> %void {
-    var x = true;
-    while (x) {
-        x = false;
-    }
-    %%io.stdout.printf("OK\n");
-}
-    )SOURCE", "OK\n");
-
-
     add_simple_case("incomplete struct parameter top level decl", R"SOURCE(
 const io = @import("std").io;
 struct A {
test/self_hosted.zig
@@ -1166,3 +1166,39 @@ fn statically_initialized_array_literal() {
     assert(y[3] == 4);
 }
 const st_init_arr_lit_x = []u8{1,2,3,4};
+
+
+
+#attribute("test")
+fn pointer_to_void_return_type() {
+    %%test_pointer_to_void_return_type();
+}
+fn test_pointer_to_void_return_type() -> %void {
+    const a = test_pointer_to_void_return_type_2();
+    return *a;
+}
+const test_pointer_to_void_return_type_x = void{};
+fn test_pointer_to_void_return_type_2() -> &void {
+    return &test_pointer_to_void_return_type_x;
+}
+
+
+#attribute("test")
+fn call_result_of_if_else_expression() {
+    assert(str_eql(f2(true), "a"));
+    assert(str_eql(f2(false), "b"));
+}
+fn f2(x: bool) -> []u8 {
+    return (if (x) f_a else f_b)();
+}
+fn f_a() -> []u8 { "a" }
+fn f_b() -> []u8 { "b" }
+
+
+#attribute("test")
+fn const_expression_eval_handling_of_variables() {
+    var x = true;
+    while (x) {
+        x = false;
+    }
+}