Skip to content

Commit

Permalink
Add scalar example to loop invariant violation test #19
Browse files Browse the repository at this point in the history
  • Loading branch information
riftEmber committed Nov 25, 2021
1 parent 8d6f76e commit 91a3bef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/ComputationBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ TEST_F(ComputationBuilderDeathTest, incorrect_increment_fails) {
}

TEST_F(ComputationBuilderDeathTest, loop_invariant_violation_fails) {
std::string code =
std::string code1 =
"int* a() {\
int x[5];\
for (int i = 0; i < 5; i++) {\
Expand All @@ -370,8 +370,19 @@ TEST_F(ComputationBuilderDeathTest, loop_invariant_violation_fails) {
}\
return x;\
}";
ASSERT_DEATH(buildComputationFromCode(code),
ASSERT_DEATH(buildComputationFromCode(code1),
"Code may not modify loop-invariant data space 'x'");

std::string code2 =
"int* a() {\
int N = 5;\
for (int i = 0; i < N; i += 1) {\
N = 3;\
}\
return N;\
}";
ASSERT_DEATH(buildComputationFromCode(code2),
"Code may not modify loop-invariant data space 'N'");
}

TEST_F(ComputationBuilderDeathTest, unsupported_statement_fails) {
Expand Down

0 comments on commit 91a3bef

Please sign in to comment.