move 2 tests to self hosted land
parent
c899368a90
commit
832454f38b
|
@ -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");
|
)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(
|
add_simple_case_libc("expose function pointer to C land", R"SOURCE(
|
||||||
const c = @c_import(@c_include("stdlib.h"));
|
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");
|
)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(
|
add_simple_case("incomplete struct parameter top level decl", R"SOURCE(
|
||||||
const io = @import("std").io;
|
const io = @import("std").io;
|
||||||
struct A {
|
struct A {
|
||||||
|
|
|
@ -1166,3 +1166,39 @@ fn statically_initialized_array_literal() {
|
||||||
assert(y[3] == 4);
|
assert(y[3] == 4);
|
||||||
}
|
}
|
||||||
const st_init_arr_lit_x = []u8{1,2,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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue