Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsajdak committed Apr 22, 2023
1 parent b43670b commit 8fddc94
Show file tree
Hide file tree
Showing 16 changed files with 522 additions and 0 deletions.
165 changes: 165 additions & 0 deletions regression-tests/pure2-nested-ifs-conditions-error.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
main: (args) =
{
a := 1;
b := 2;
c := 3;
d := 4;

{
p : *int;

// no initialization in selection_node
if args.argc > 20 {
c = 20;
} else if args.argc > 10 {
c = 10;
} else {
if args.argc % 2 {
b = 2;
} else {
b = 1;
}
}

// initialization in first if condition
if p = b& {
p = a&;
} else if args.argc == 3 {
p = b&;
if args.argc == 2 {
p = c&;
} else {
if b > 0 {
p = a&;
}
else {
p = d&;
}
}
} else {
p = c&;
}

std::cout << p* << std::endl;
}

{
p : *int;

// initialization in:
// - first if branch
// - second if condition
if args.argc == 3 {
p = a&;
} else if p = b& {
p = b&;
if args.argc == 2 {
p = c&;
} else {
if b > 0 {
p = a&;
}
else {
p = d&;
}
}
} else {
p = c&;
}

std::cout << p* << std::endl;
}

{
p : *int;

// initialization in:
// - first if branch
// - second if branch in nested if condition (first if)
// - else branch
if args.argc == 3 {
p = a&;
} else if args.argc == 2 {
if p = b& {
p = c&;
} else {
if b > 0 {
p = a&;
}
else {
p = d&;
}
}
} else {
p = c&;
}

std::cout << p* << std::endl;
}

{
p : *int;

// initialization in:
// - first if branch
// - second if branch in nested if:
// - first branch
// - second branch in nested if condition (first if)
// - else branch
if args.argc == 3 {
p = a&;
} else if args.argc == 2 {
if b > 0 {
p = c&;
} else {
if p = b& {
p = a&;
}
else {
p = d&;
}
p* = 42;
}
p* = 24;
} else {
p = c&;
}

std::cout << p* << std::endl;
}

{
p : *int;

// initialization in:
// - first if branch
// - second if branch in nested if:
// - first branch
// - second branch in nested if:
// - first if branch
// - second if condition
// - else branch
if args.argc == 3 {
p = a&;
} else if args.argc == 2 {
if b > 0 {
p = c&;
} else {
if b > 2 {
p = a&;
}
else if p = b& {
d = p*;
}
else {
p = d&;
}
}
} else {
p = c&;
}

std::cout << p* << std::endl;
}

}
27 changes: 27 additions & 0 deletions regression-tests/pure2-nested-ifs-error.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
main: (args) = {
p : *int;

a := 1;
b := 2;
c := 3;
d := 4;

if args.argc == 3 {
p = a&;
} else if b > 2 {
if args.argc == 2 {
p = c&;
} else {
if b > 0 {
p = a&;
}
else {
p = d&;
}
}
} else {
// p = c&;
}

std::cout << p* << std::endl;
}
52 changes: 52 additions & 0 deletions regression-tests/pure2-nested-ifs.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
main: (args) =
{
a := 1;
b := 2;
c := 3;
d := 4;

{
p : *int;

// no initialization in selection_node
if args.argc > 20 {
c = 20;
} else if args.argc > 10 {
c = 10;
} else {
if args.argc % 2 {
b = 2;
} else {
b = 1;
}
}

// initialization in:
// - first if branch
// - second if branch in nested if:
// - first branch
// - second branch in nested if:
// - first if branch
// - else branch
// - else branch
if args.argc == 3 {
p = a&;
} else if args.argc == 2 {
if b > 0 {
p = c&;
} else {
if b > 2 {
p = a&;
}
else {
p = d&;
}
}
} else {
p = c&;
}

std::cout << p* << std::endl;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Empty file.
Loading

0 comments on commit 8fddc94

Please sign in to comment.