Skip to content

Commit dcc3cbe

Browse files
authored
#2275. More noSuchMethod tests added. Part 2 (#2288)
More `noSuchMethod` tests added. Part 2
1 parent cb63ec0 commit dcc3cbe

13 files changed

+711
-37
lines changed

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A01_t01.dart

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/// @description Checks that it is possible to define a `noSuchMethod` which
2323
/// is a correct override of `noSuchMethod` in `Object`.
2424
/// @author [email protected]
25+
/// @issue 53640
2526
2627
import "../../../../Utils/expect.dart";
2728

@@ -50,6 +51,68 @@ class C5 {
5051
int noSuchMethod(Invocation i) => 5;
5152
}
5253

54+
mixin M1 {
55+
int m();
56+
void noSuchMethod(Invocation i) {}
57+
}
58+
59+
mixin M2 {
60+
int m();
61+
Object? noSuchMethod(Invocation i) => 2;
62+
}
63+
64+
mixin M3 {
65+
int m();
66+
Null noSuchMethod(Invocation i) => null;
67+
}
68+
69+
mixin M4 {
70+
int m();
71+
Never noSuchMethod(Invocation i) => throw 42;
72+
}
73+
74+
mixin M5 {
75+
int m();
76+
int noSuchMethod(Invocation i) => 5;
77+
}
78+
79+
class MA1 = Object with M1;
80+
class MA2 = Object with M2;
81+
class MA3 = Object with M3;
82+
class MA4 = Object with M4;
83+
class MA5 = Object with M5;
84+
85+
enum E1 {
86+
e1, e2;
87+
int m();
88+
void noSuchMethod(Invocation i) {}
89+
}
90+
91+
enum E2 {
92+
e1, e2;
93+
int m();
94+
Object? noSuchMethod(Invocation i) => 2;
95+
}
96+
97+
enum E3 {
98+
e1, e2;
99+
int m();
100+
Null noSuchMethod(Invocation i) => null;
101+
}
102+
103+
enum E4 {
104+
e1, e2;
105+
int m();
106+
Never noSuchMethod(Invocation i) => throw 42;
107+
}
108+
109+
enum E5 {
110+
e1, e2;
111+
int m();
112+
int noSuchMethod(Invocation i) => 5;
113+
}
114+
115+
53116
main() {
54117
Expect.throws(() {
55118
C1().m();
@@ -62,4 +125,28 @@ main() {
62125
C4().m();
63126
});
64127
Expect.equals(5, C5().m());
128+
129+
Expect.throws(() {
130+
MA1().m();
131+
});
132+
Expect.equals(2, MA2().m());
133+
Expect.throws(() {
134+
MA3().m();
135+
});
136+
Expect.throws(() {
137+
MA4().m();
138+
});
139+
Expect.equals(5, MA5().m());
140+
141+
Expect.throws(() {
142+
E1.e1.m();
143+
});
144+
Expect.equals(2, E2.e1.m());
145+
Expect.throws(() {
146+
E3.e1.m();
147+
});
148+
Expect.throws(() {
149+
E4.e1.m();
150+
});
151+
Expect.equals(5, E5.e1.m());
65152
}

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A01_t02.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,40 @@ class C2 {
3737
dynamic noSuchMethod(Invocation i, {int x = 2}) => x;
3838
}
3939

40+
mixin M1 {
41+
int m();
42+
dynamic noSuchMethod(Invocation i, [int x = 1]) {
43+
return x;
44+
}
45+
}
46+
47+
mixin M2 {
48+
int m();
49+
dynamic noSuchMethod(Invocation i, {int x = 2}) => x;
50+
}
51+
52+
class MA1 = Object with M1;
53+
class MA2 = Object with M2;
54+
55+
enum E1 {
56+
e1, e2;
57+
int m();
58+
dynamic noSuchMethod(Invocation i, [int x = 1]) {
59+
return x;
60+
}
61+
}
62+
63+
enum E2 {
64+
e1, e2;
65+
int m();
66+
dynamic noSuchMethod(Invocation i, {int x = 2}) => x;
67+
}
68+
4069
main() {
4170
Expect.equals(1, C1().m());
4271
Expect.equals(2, C2().m());
72+
Expect.equals(1, MA1().m());
73+
Expect.equals(2, MA2().m());
74+
Expect.equals(1, E1.e1.m());
75+
Expect.equals(2, E2.e2.m());
4376
}

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A01_t03.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,42 @@ class C2 {
3535
dynamic noSuchMethod(covariant Invocation i) => 2;
3636
}
3737

38+
mixin M1 {
39+
int m();
40+
external dynamic noSuchMethod(Invocation i);
41+
}
42+
43+
mixin M2 {
44+
int m();
45+
dynamic noSuchMethod(covariant Invocation i) => 2;
46+
}
47+
48+
class MA1 = Object with M1;
49+
class MA2 = Object with M2;
50+
51+
enum E1 {
52+
e1, e2;
53+
int m();
54+
external dynamic noSuchMethod(Invocation i);
55+
}
56+
57+
enum E2 {
58+
e1, e2;
59+
int m();
60+
dynamic noSuchMethod(covariant Invocation i) => 2;
61+
}
62+
3863
main() {
3964
Expect.throws(() {
4065
C1().m();
4166
});
4267
Expect.equals(2, C2().m());
68+
Expect.throws(() {
69+
MA1().m();
70+
});
71+
Expect.equals(2, MA2().m());
72+
Expect.throws(() {
73+
E1.e1.m();
74+
});
75+
Expect.equals(2, E2.e2.m());
4376
}

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A01_t04.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,36 @@
2222
/// @description Checks that it is possible to define a `noSuchMethod` which
2323
/// is a correct override of `noSuchMethod` in `Object`.
2424
/// @author [email protected]
25+
/// @issue 53640
2526
2627
import "../../../../Utils/expect.dart";
2728

28-
class C1 {
29+
class C {
30+
int m();
31+
dynamic noSuchMethod(covariant Object o) => o;
32+
}
33+
34+
mixin M {
35+
int m();
36+
dynamic noSuchMethod(covariant Object o) => o;
37+
}
38+
39+
class MA = Object with M;
40+
41+
enum E {
42+
e1, e2;
2943
int m();
3044
dynamic noSuchMethod(covariant Object o) => o;
3145
}
3246

3347
main() {
3448
Expect.throws(() {
35-
C1().m();
49+
C().m();
50+
});
51+
Expect.throws(() {
52+
print(MA().m());
53+
});
54+
Expect.throws(() {
55+
E.e1.m();
3656
});
3757
}

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A02_t01.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,77 @@ class C4 {
5151
// [cfe] unspecified
5252
}
5353

54+
mixin M1 {
55+
void noSuchMethod() {}
56+
// ^^^^^^^^^^^^
57+
// [analyzer] unspecified
58+
// [cfe] unspecified
59+
}
60+
61+
mixin M2 {
62+
void noSuchMethod(Invocation i, String s) {}
63+
// ^^^^^^^^^^^^
64+
// [analyzer] unspecified
65+
// [cfe] unspecified
66+
}
67+
68+
mixin M3 {
69+
void noSuchMethod(Invocation i, {required String s}) {}
70+
// ^^^^^^^^^^^^
71+
// [analyzer] unspecified
72+
// [cfe] unspecified
73+
}
74+
75+
mixin M4 {
76+
dynamic noSuchMethod(int i) => i;
77+
// ^^^^^^^^^^^^
78+
// [analyzer] unspecified
79+
// [cfe] unspecified
80+
}
81+
82+
enum E1 {
83+
e1, e2;
84+
void noSuchMethod() {}
85+
// ^^^^^^^^^^^^
86+
// [analyzer] unspecified
87+
// [cfe] unspecified
88+
}
89+
90+
enum E2 {
91+
e1, e2;
92+
void noSuchMethod(Invocation i, String s) {}
93+
// ^^^^^^^^^^^^
94+
// [analyzer] unspecified
95+
// [cfe] unspecified
96+
}
97+
98+
enum E3 {
99+
e1, e2;
100+
void noSuchMethod(Invocation i, {required String s}) {}
101+
// ^^^^^^^^^^^^
102+
// [analyzer] unspecified
103+
// [cfe] unspecified
104+
}
105+
106+
enum E4 {
107+
e1, e2;
108+
dynamic noSuchMethod(int i) => i;
109+
// ^^^^^^^^^^^^
110+
// [analyzer] unspecified
111+
// [cfe] unspecified
112+
}
113+
54114
main() {
55115
print(C1);
56116
print(C2);
57117
print(C3);
58118
print(C4);
119+
print(M1);
120+
print(M2);
121+
print(M3);
122+
print(M4);
123+
print(E1);
124+
print(E2);
125+
print(E3);
126+
print(E4);
59127
}

Language/Classes/Instance_Methods/Method_noSuchMethod/definition_A02_t02.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,77 @@ class C4 {
5151
// [cfe] unspecified
5252
}
5353

54+
mixin M1 {
55+
external void noSuchMethod();
56+
// ^^^^^^^^^^^^
57+
// [analyzer] unspecified
58+
// [cfe] unspecified
59+
}
60+
61+
mixin M2 {
62+
external void noSuchMethod(Invocation i, String s);
63+
// ^^^^^^^^^^^^
64+
// [analyzer] unspecified
65+
// [cfe] unspecified
66+
}
67+
68+
mixin M3 {
69+
external void noSuchMethod(Invocation i, {required String s});
70+
// ^^^^^^^^^^^^
71+
// [analyzer] unspecified
72+
// [cfe] unspecified
73+
}
74+
75+
mixin M4 {
76+
external dynamic noSuchMethod(int i);
77+
// ^^^^^^^^^^^^
78+
// [analyzer] unspecified
79+
// [cfe] unspecified
80+
}
81+
82+
enum E1 {
83+
e1, e2;
84+
external void noSuchMethod();
85+
// ^^^^^^^^^^^^
86+
// [analyzer] unspecified
87+
// [cfe] unspecified
88+
}
89+
90+
enum E2 {
91+
e1, e2;
92+
external void noSuchMethod(Invocation i, String s);
93+
// ^^^^^^^^^^^^
94+
// [analyzer] unspecified
95+
// [cfe] unspecified
96+
}
97+
98+
enum E3 {
99+
e1, e2;
100+
external void noSuchMethod(Invocation i, {required String s});
101+
// ^^^^^^^^^^^^
102+
// [analyzer] unspecified
103+
// [cfe] unspecified
104+
}
105+
106+
enum E4 {
107+
e1, e2;
108+
external dynamic noSuchMethod(int i);
109+
// ^^^^^^^^^^^^
110+
// [analyzer] unspecified
111+
// [cfe] unspecified
112+
}
113+
54114
main() {
55115
print(C1);
56116
print(C2);
57117
print(C3);
58118
print(C4);
119+
print(M1);
120+
print(M2);
121+
print(M3);
122+
print(M4);
123+
print(E1);
124+
print(E2);
125+
print(E3);
126+
print(E4);
59127
}

0 commit comments

Comments
 (0)