authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-16 14:58:22-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-16 14:58:22-05:00
log98faf4f74984db615ba62de285308dfc5092ec7c
tree07cca4cc3aabf47ed00bd7a2eba79eaa35aae542
parentc715309bc5de874d3d418c80095d50f7efc17001

add test for short-circuit AND and OR assignment

closes #31

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

test/cases/bool.zig+14
...@@ -30,3 +30,17 @@ fn boolCmp() {...@@ -30,3 +30,17 @@ fn boolCmp() {
30fn testBoolCmp(a: bool, b: bool) -> bool {30fn testBoolCmp(a: bool, b: bool) -> bool {
31 a == b31 a == b
32}32}
33
34fn shortCircuitAndOr() {
35 @setFnTest(this);
36
37 var a = true;
38 a &&= false;
39 assert(!a);
40 a &&= true;
41 assert(!a);
42 a ||= false;
43 assert(!a);
44 a ||= true;
45 assert(a);
46}