diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-01-16 14:58:22 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-01-16 14:58:22 -0500 |
| commit | 98faf4f74984db615ba62de285308dfc5092ec7c (patch) | |
| tree | 07cca4cc3aabf47ed00bd7a2eba79eaa35aae542 | |
| parent | c715309bc5de874d3d418c80095d50f7efc17001 (diff) | |
| download | zig-98faf4f74984db615ba62de285308dfc5092ec7c.tar.gz zig-98faf4f74984db615ba62de285308dfc5092ec7c.zip | |
add test for short-circuit AND and OR assignment
closes #31
| -rw-r--r-- | test/cases/bool.zig | 14 |
1 files changed, 14 insertions, 0 deletions
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); +} |
