fix tests and add %% operator test

master
Andrew Kelley 2016-01-25 14:04:29 -07:00
parent 6db6609df8
commit 4b9e1dd438
2 changed files with 24 additions and 1 deletions

View File

@ -498,7 +498,7 @@ static void resolve_function_proto(CodeGen *g, AstNode *node, FnTableEntry *fn_t
// next, loop over the parameters again and compute debug information
// and codegen information
bool first_arg_return = handle_is_ptr(return_type);
bool first_arg_return = !fn_proto->skip && handle_is_ptr(return_type);
// +1 for maybe making the first argument the return value
LLVMTypeRef *gen_param_types = allocate<LLVMTypeRef>(1 + src_param_count);
// +1 because 0 is the return type and +1 for maybe making first arg ret val

View File

@ -1254,6 +1254,29 @@ pub fn main(args: [][]u8) %void => {
stdout.printf("BAD\n");
}
stdout.printf("OK\n");
}
)SOURCE", "OK\n");
add_simple_case("%% binary operator", R"SOURCE(
import "std.zig";
error ItBroke;
fn g(x: bool) %isize => {
if (x) {
error.ItBroke
} else {
10
}
}
pub fn main(args: [][]u8) %void => {
const a = g(true) %% 3;
const b = g(false) %% 3;
if (a != 3) {
stdout.printf("BAD\n");
}
if (b != 10) {
stdout.printf("BAD\n");
}
stdout.printf("OK\n");
}
)SOURCE", "OK\n");
}