Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
  • Loading branch information
DanilaFe committed Sep 16, 2024
1 parent 2e41666 commit 550c076
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions frontend/test/resolution/testTuples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,32 @@ static void test20() {
}
}

static void test21() {
// Ensure that (type int, type int) tuples in type expression are properly
// handled when they are specifying the type of var or const variable.

Context ctx;
Context* context = &ctx;
auto program = R"""(
var x: 2*int = (7,3);
const y: 2*int = (7,3);
var x2: 2*int;
const y2: 2*int;
param firstMatch = x.type == x2.type;
param secondMatch = y.type == y2.type;
)""";

auto vars = resolveTypesOfVariables(context, program,
{"x", "y", "x2", "y2", "firstMatch", "secondMatch"});
assert(vars["x"].type()->isTupleType());
assert(vars["y"].type()->isTupleType());
assert(vars["x2"].type()->isTupleType());
assert(vars["y2"].type()->isTupleType());
ensureParamBool(vars["firstMatch"], true);
ensureParamBool(vars["secondMatch"], true);
}


int main() {
test1();
Expand Down Expand Up @@ -998,5 +1024,6 @@ int main() {
testTupleGeneric();

test20();
test21();
return 0;
}

0 comments on commit 550c076

Please sign in to comment.