authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-25 14:04:29-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-25 14:04:29-07:00
log4b9e1dd438827c054adc5316a0ccaf62486ac66c
treea7bad779a5941ca3ef7cd759e42bc5877d3c7b6f
parent6db6609df84bedafebc709bc5865e7f18c862cc6

fix tests and add %% operator test


2 files changed, 24 insertions(+), 1 deletions(-)

src/analyze.cpp+1-1
......@@ -498,7 +498,7 @@ static void resolve_function_proto(CodeGen *g, AstNode *node, FnTableEntry *fn_t
498498
499499 // next, loop over the parameters again and compute debug information
500500 // and codegen information
501 bool first_arg_return = handle_is_ptr(return_type);
501 bool first_arg_return = !fn_proto->skip && handle_is_ptr(return_type);
502502 // +1 for maybe making the first argument the return value
503503 LLVMTypeRef *gen_param_types = allocate<LLVMTypeRef>(1 + src_param_count);
504504 // +1 because 0 is the return type and +1 for maybe making first arg ret val
test/run_tests.cpp+23
......@@ -1254,6 +1254,29 @@ pub fn main(args: [][]u8) %void => {
12541254 stdout.printf("BAD\n");
12551255 }
12561256 stdout.printf("OK\n");
1257}
1258 )SOURCE", "OK\n");
1259
1260 add_simple_case("%% binary operator", R"SOURCE(
1261import "std.zig";
1262error ItBroke;
1263fn g(x: bool) %isize => {
1264 if (x) {
1265 error.ItBroke
1266 } else {
1267 10
1268 }
1269}
1270pub fn main(args: [][]u8) %void => {
1271 const a = g(true) %% 3;
1272 const b = g(false) %% 3;
1273 if (a != 3) {
1274 stdout.printf("BAD\n");
1275 }
1276 if (b != 10) {
1277 stdout.printf("BAD\n");
1278 }
1279 stdout.printf("OK\n");
12571280}
12581281 )SOURCE", "OK\n");
12591282}