Skip to content

#3057. Add pattern assignment cases to C-style for tests #3126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 83 additions & 4 deletions TypeSystem/flow-analysis/reachability_for_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
/// `C` is a definite assignment.
/// @author [email protected]

class C {
int v;
C(this.v);
}

test1() {
int i;
for (; (i = 42) < 0;) {
}
for (; (i = 42) < 0;) {}
i; // Definitely assigned.
}

Expand All @@ -28,19 +32,94 @@ test2() {
[
for (; (i = 42) < 0;) 0
];
i; // Definitely assigned.
i;
}

test3() {
int i;
<int, int>{
for (; (i = 42) < 0;) 0: 0
};
i; // Definitely assigned.
i;
}

test4() {
int i;
for (; ((i,) = (42,)) == 0;) {}
i;
}

test5() {
int i;
for (; ((x: i) = (x: 42)) == 0;) {}
i;
}

test6() {
int i;
for (; (C(v: i) = C(42)) == 0;) {}
i;
}

test7() {
int i;
[
for (; ((i,) = (42,)) == 0;) 0
];
i;
}

test8() {
int i;
[
for (; ((x: i) = (x: 42)) == 0;) 0
];
i;
}

test9() {
int i;
[
for (; (C(v: i) = C(42)) == 0;) 0
];
i;
}

test10() {
int i;
<int, int>{
for (; ((i,) = (42,)) == 0;) 0: 0
};
i;
}

test11() {
int i;
<int, int>{
for (; ((x: i) = (x: 42)) == 0;) 0: 0
};
i;
}

test12() {
int i;
<int, int>{
for (; (C(v: i) = C(42)) == 0;) 0: 0
};
i;
}

main() {
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
test11();
test12();
}
83 changes: 83 additions & 0 deletions TypeSystem/flow-analysis/reachability_for_A01_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
/// `before(C)`.
/// @author [email protected]

class C {
int v;
C(this.v);
}

test1() {
int n;
for (n = 42; n > 0;) { // n definitely assigned
Expand All @@ -39,8 +44,86 @@ test3() {
};
}

test4() {
int n;
for ((n,) = (42,); n > 0;) {
break;
}
}

test5() {
int n;
for ((x: n) = (x: 42); n > 0;) {
break;
}
}

test6() {
int n;
for (C(v: n) = C(42); n > 0;) {
break;
}
}

test7() {
int n;
[
for ((n,) = (42,); n < 0;)
0
];
}

test8() {
int n;
[
for ((x: n) = (x: 42); n < 0;)
0
];
}

test9() {
int n;
[
for (C(v: n) = C(42); n < 0;)
0
];
}

test10() {
int n;
<int, int>{
for ((n,) = (42,); n < 0;)
0: 0
};
}

test11() {
int n;
<int, int>{
for ((x: n) = (x: 42); n < 0;)
0: 0
};
}

test12() {
int n;
<int, int>{
for (C(v: n) = C(42); n < 0;)
0: 0
};
}

main() {
test1();
test2();
test3();
test4();
test5();
test6();
test7();
test8();
test9();
test10();
test11();
test12();
}
56 changes: 56 additions & 0 deletions TypeSystem/flow-analysis/reachability_for_A01_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
/// that `assignedIn(U)` is detected by flow analysis.
/// @author [email protected]

class C {
int v;
C(this.v);
}

test1() {
late int n;
for (
Expand Down Expand Up @@ -63,8 +68,59 @@ test3() {
};
}

test4() {
late int n;
for (
;
() {
if (1 > 2) {
n; // possibly assigned
}
return true;
}();
(n,) = (42,)
) {}
}

test5() {
late int n;
[
for (
;
() {
if (1 > 2) {
n;
}
return true;
}();
(x: n) = (x: 42)
)
0,
];
}

test6() {
late int n;
<int, int>{
for (
;
() {
if (1 > 2) {
n;
}
return true;
}();
C(v: n) = C(42)
)
0: 0,
};
}

main() {
print(test1);
print(test2);
print(test3);
print(test4);
print(test5);
print(test6);
}
73 changes: 73 additions & 0 deletions TypeSystem/flow-analysis/reachability_for_A01_t05.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
/// that `assignedIn(S)` is detected by flow analysis.
/// @author [email protected]

class C {
int v;
C(this.v);
}

test1() {
late int n;
for (
Expand Down Expand Up @@ -78,9 +83,77 @@ test4() {
};
}

test5() {
late int n;
for (
;
() {
if (1 > 2) {
n; // possibly assigned
}
return true;
}();
) {
(n,) = (42,);
}
}

test6() {
late int n;
[
for (
;
() {
if (1 > 2) {
n;
}
return true;
}();
)
(x: n) = (x: 42),
];
}

test7() {
late int n;
<C, int>{
for (
;
() {
if (1 > 2) {
n;
}
return true;
}();
)
(C(v: n) = C(42)): 0,
};
}

test8() {
late int n;
<int, C>{
for (
;
() {
if (1 > 2) {
n;
}
return true;
}();
)
0: (C(v: n) = C(42)),
};
}


main() {
print(test1);
print(test2);
print(test3);
print(test4);
print(test5);
print(test6);
print(test7);
print(test8);
}
Loading