authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2015-12-03 12:19:28-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2015-12-03 12:19:28-07:00
log22fccdbb0d771897568dd6f1603102007a5d2c5b
tree2c5d37004a609ea7bb1cffa80460e899611814b6
parentf1aaf1353e12aa39bd6f89588852a1c70e8424b3

tests for bool stuff


1 files changed, 22 insertions(+), 0 deletions(-)

test/run_tests.cpp+22
......@@ -273,6 +273,22 @@ export fn _start() -> unreachable {
273273 exit(0);
274274}
275275 )SOURCE", "OK\n");
276
277 add_simple_case("bool literals", R"SOURCE(
278#link("c")
279extern {
280 fn puts(s: *const u8) -> i32;
281 fn exit(code: i32) -> unreachable;
282}
283
284export fn _start() -> unreachable {
285 if (true) { puts("OK 1"); }
286 if (false) { puts("BAD 1"); }
287 if (!true) { puts("BAD 2"); }
288 if (!false) { puts("OK 2"); }
289 exit(0);
290}
291 )SOURCE", "OK 1\nOK 2\n");
276292}
277293
278294static void add_compile_failure_test_cases(void) {
......@@ -382,6 +398,12 @@ fn f() -> i32 {
382398}
383399 )SOURCE", 1, ".tmp_source.zig:2:15: error: type mismatch. expected i32. got *const u8");
384400
401 add_compile_fail_case("if condition is bool, not int", R"SOURCE(
402fn f() {
403 if (0) {}
404}
405 )SOURCE", 1, ".tmp_source.zig:3:9: error: type mismatch. expected bool. got i32");
406
385407}
386408
387409static void print_compiler_invokation(TestCase *test_case, Buf *zig_stderr) {