Skip to content

Commit f292410

Browse files
committed
Add test for new operators
Signed-off-by: Anna Rift <[email protected]>
1 parent ba288c6 commit f292410

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

frontend/test/resolution/testResolve.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,30 @@ static void test27() {
17301730
assert(guard.realizeErrors() == 0);
17311731
}
17321732

1733+
// Test resolving logical AND/OR compound assignment operators
1734+
static void test28() {
1735+
Context ctx;
1736+
Context* context = &ctx;
1737+
ErrorGuard guard(context);
1738+
1739+
std::string prog =
1740+
R"""(
1741+
proc baz() {
1742+
var ok = true;
1743+
ok &&= false;
1744+
ok ||= true;
1745+
return ok;
1746+
}
1747+
var x = baz();
1748+
)""";
1749+
1750+
auto t = resolveTypeOfXInit(context, prog);
1751+
CHPL_ASSERT(!t.isUnknownOrErroneous());
1752+
CHPL_ASSERT(t.type()->isBoolType());
1753+
1754+
assert(guard.realizeErrors() == 0);
1755+
}
1756+
17331757
// This bug is hard to replicate with queries alone, but does seem to show
17341758
// up in some cases of the query system.
17351759
static void testInfiniteCycleBug() {
@@ -2128,6 +2152,7 @@ int main() {
21282152
test25();
21292153
test26();
21302154
test27();
2155+
test28();
21312156

21322157
testInfiniteCycleBug();
21332158

0 commit comments

Comments
 (0)