Skip to content

Commit 744be56

Browse files
committed
Add test of correct short-circuiting for logical assignment ops
Signed-off-by: Anna Rift <[email protected]>
1 parent e53a2c8 commit 744be56

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
proc returnsBool() {
2+
writeln("evaluated");
3+
return true;
4+
}
5+
6+
var x : bool;
7+
8+
writeln("shouldn't short-circuit for &&= with LHS true");
9+
x = true;
10+
x &&= returnsBool();
11+
writeln();
12+
13+
writeln("should short-circuit for &&= with LHS false");
14+
x = false;
15+
x &&= returnsBool();
16+
writeln();
17+
18+
writeln("should short-circuit for ||= with LHS true");
19+
x = true;
20+
x ||= returnsBool();
21+
writeln();
22+
23+
writeln("shouldn't short-circuit for ||= with LHS false");
24+
x = false;
25+
x ||= returnsBool();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
shouldn't short-circuit for &&= with LHS true
2+
evaluated
3+
4+
should short-circuit for &&= with LHS false
5+
6+
should short-circuit for ||= with LHS true
7+
8+
shouldn't short-circuit for ||= with LHS false
9+
evaluated

0 commit comments

Comments
 (0)