From 98faf4f74984db615ba62de285308dfc5092ec7c Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 16 Jan 2017 14:58:22 -0500 Subject: [PATCH] add test for short-circuit AND and OR assignment closes #31 --- test/cases/bool.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/cases/bool.zig b/test/cases/bool.zig index 2f5c7d42e7..b449c0a816 100644 --- a/test/cases/bool.zig +++ b/test/cases/bool.zig @@ -30,3 +30,17 @@ fn boolCmp() { fn testBoolCmp(a: bool, b: bool) -> bool { a == b } + +fn shortCircuitAndOr() { + @setFnTest(this); + + var a = true; + a &&= false; + assert(!a); + a &&= true; + assert(!a); + a ||= false; + assert(!a); + a ||= true; + assert(a); +}