Skip to content

Commit 5430e68

Browse files
lrhnCommit Queue
authored andcommitted
Remove unnecessary leftover @dart=2.19 from tests.
Change-Id: I6d5e15ff2d432202618fbc490969a65a9181816d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396281 Reviewed-by: Nicholas Shahan <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]>
1 parent dbc9c86 commit 5430e68

File tree

215 files changed

+4647
-1879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+4647
-1879
lines changed

pkg/expect/lib/static_type_helper.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Object? context<T>(T x) => x;
1717
T contextType<T>(Object? result) => result as T;
1818

1919
extension StaticType<T> on T {
20-
/// Check the static type.
20+
/// Check the static type against another type wrt. sub- and supertype.
2121
///
2222
/// Use as follows (assuming `e` has static type `num`):
2323
/// ```dart
@@ -45,6 +45,18 @@ extension StaticType<T> on T {
4545
callback<T>();
4646
return this;
4747
}
48+
49+
/// The static type as a `Type` object.
50+
///
51+
/// Can be used for doing "same type" equality checks, like
52+
/// ```dart
53+
/// Expect(typeOf<int Function(int)>(), value.functionName.staticType);
54+
/// ```
55+
/// The [Type.operator==] distinguishes some types that are equivalent
56+
/// wrt. super- and sub-typing, like `dynamic` and `Object?`.
57+
/// It also performs normalization, so `typeOf<FutureOr<Object>> == Object`,
58+
/// even if they differ as static types.
59+
Type get staticType => T;
4860
}
4961

5062
/// Invokes [callback] with the static type of [value].

pkg/test_runner/lib/src/test_file.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ abstract class _TestFileBase {
6464

6565
/// The parsed error expectation markers in this test, if it is a static
6666
/// error test.
67+
///
68+
/// If empty, the test is not a static error test.
6769
final List<StaticError> expectedErrors;
6870

6971
/// The name of the multitest section this file corresponds to if it was
@@ -358,7 +360,6 @@ class TestFile extends _TestFileBase {
358360
result
359361
.addAll(_parseExpectations(uriString, alreadyParsed: alreadyParsed));
360362
}
361-
362363
return result;
363364
}
364365

tests/language/async/switch_test.dart

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ foo1(int a) async {
1919
case 2:
2020
k += a;
2121
return k + 2;
22-
default: k = 2; //# withDefault: ok
2322
}
2423
return k;
2524
}
@@ -34,7 +33,6 @@ foo2(Future<int> a) async {
3433
case 2:
3534
k += await a;
3635
return k + 2;
37-
default: k = 2; //# withDefault: ok
3836
}
3937
return k;
4038
}
@@ -48,7 +46,6 @@ foo3(int a) async {
4846
case 2:
4947
k += a;
5048
return k + 2;
51-
default: k = 2; //# withDefault: ok
5249
}
5350
return k;
5451
}
@@ -62,7 +59,64 @@ foo4(value) async {
6259
case 2:
6360
k += 2;
6461
return 2 + k;
65-
default: k = 2; //# withDefault: ok
62+
}
63+
return k;
64+
}
65+
66+
foo1WithDefault(int a) async {
67+
int k = 0;
68+
switch (a) {
69+
case 1:
70+
await 3;
71+
k += 1;
72+
break;
73+
case 2:
74+
k += a;
75+
return k + 2;
76+
default: k = 2;
77+
}
78+
return k;
79+
}
80+
81+
foo2WithDefault(Future<int> a) async {
82+
int k = 0;
83+
switch (await a) {
84+
case 1:
85+
await 3;
86+
k += 1;
87+
break;
88+
case 2:
89+
k += await a;
90+
return k + 2;
91+
default: k = 2;
92+
}
93+
return k;
94+
}
95+
96+
foo3WithDefault(int a) async {
97+
int k = 0;
98+
switch (a) {
99+
case 1:
100+
k += 1;
101+
break;
102+
case 2:
103+
k += a;
104+
return k + 2;
105+
default: k = 2;
106+
}
107+
return k;
108+
}
109+
110+
foo4WithDefault(value) async {
111+
int k = 0;
112+
switch (await value) {
113+
case 1:
114+
k += 1;
115+
break;
116+
case 2:
117+
k += 2;
118+
return 2 + k;
119+
default: k = 2;
66120
}
67121
return k;
68122
}
@@ -72,20 +126,20 @@ Future<int> futureOf(int a) async => await a;
72126
Future test() async {
73127
Expect.equals(1, await foo1(1));
74128
Expect.equals(4, await foo1(2));
75-
Expect.equals(2, await foo1(3)); //# withDefault: ok
76-
Expect.equals(0, await foo1(3)); //# none: ok
129+
Expect.equals(2, await foo1WithDefault(3));
130+
Expect.equals(0, await foo1(3));
77131
Expect.equals(1, await foo2(futureOf(1)));
78132
Expect.equals(4, await foo2(futureOf(2)));
79-
Expect.equals(2, await foo2(futureOf(3))); //# withDefault: ok
80-
Expect.equals(0, await foo2(futureOf(3))); //# none: ok
133+
Expect.equals(2, await foo2WithDefault(futureOf(3)));
134+
Expect.equals(0, await foo2(futureOf(3)));
81135
Expect.equals(1, await foo3(1));
82136
Expect.equals(4, await foo3(2));
83-
Expect.equals(2, await foo3(3)); //# withDefault: ok
84-
Expect.equals(0, await foo3(3)); //# none: ok
137+
Expect.equals(2, await foo3WithDefault(3));
138+
Expect.equals(0, await foo3(3));
85139
Expect.equals(1, await foo4(futureOf(1)));
86140
Expect.equals(4, await foo4(futureOf(2)));
87-
Expect.equals(2, await foo4(futureOf(3))); //# withDefault: ok
88-
Expect.equals(0, await foo4(futureOf(3))); //# none: ok
141+
Expect.equals(2, await foo4WithDefault(futureOf(3)));
142+
Expect.equals(0, await foo4(futureOf(3)));
89143
}
90144

91145
void main() {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Implements Function which is not allowed in Dart 3.
6+
// @dart=2.19
7+
8+
// Dart test program to test arithmetic operations.
9+
10+
import "package:expect/expect.dart";
11+
12+
class B {}
13+
14+
class C {
15+
B call(B b) => b;
16+
}
17+
18+
class D implements Function {
19+
B call(B b) => b;
20+
}
21+
22+
typedef B BToB(B x);
23+
24+
typedef Object NullToObject(Null x);
25+
26+
main() {
27+
// The presence of a `.call` method does not cause class `C` to become a
28+
// subtype of any function type.
29+
C c = new C();
30+
Expect.throwsTypeError(() => c as BToB); //# 01: ok
31+
Expect.throwsTypeError(() => c as NullToObject); //# 02: ok
32+
Expect.throwsTypeError(() => c as Function); //# 03: ok
33+
34+
// The same goes for class `D`: `implements Function` is ignored in Dart 2.
35+
D d = new D();
36+
Expect.throwsTypeError(() => d as BToB); //# 04: ok
37+
Expect.throwsTypeError(() => d as NullToObject); //# 05: ok
38+
Expect.throwsTypeError(() => d as Function); //# 06: ok
39+
}

tests/language/call/method_as_cast_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// Implements Function which is not allowed in Dart 3.
6-
// @dart=2.19
7-
85
// Dart test program to test arithmetic operations.
96

107
import "package:expect/expect.dart";
@@ -15,7 +12,7 @@ class C {
1512
B call(B b) => b;
1613
}
1714

18-
class D implements Function {
15+
class D {
1916
B call(B b) => b;
2017
}
2118

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Implements Function which is not allowed in Dart 3.
6+
// @dart=2.19
7+
8+
// Dart test program to test arithmetic operations.
9+
10+
import "package:expect/expect.dart";
11+
12+
class C1 {
13+
int call(int i) => 2 * i;
14+
}
15+
16+
class C2 implements Function {
17+
int call(int i) => 2 * i;
18+
}
19+
20+
class D {
21+
C1 c1 = new C1();
22+
dynamic d1 = new C1();
23+
C2 c2 = new C2();
24+
dynamic d2 = new C2();
25+
26+
void test() {
27+
// Implicitly invokes c1.call(1)
28+
Expect.equals(c1(1), 2); //# 01: ok
29+
// Implicitly invokes d1.call(1)
30+
Expect.equals(d1(1), 2); //# 02: ok
31+
// Implicitly invokes c2.call(1)
32+
Expect.equals(c2(1), 2); //# 03: ok
33+
// Implicitly invokes d2.call(1)
34+
Expect.equals(d2(1), 2); //# 04: ok
35+
}
36+
}
37+
38+
main() {
39+
new D().test();
40+
// Implicitly invokes D.c1.call(1)
41+
Expect.equals(new D().c1(1), 2); //# 05: ok
42+
// Implicitly invokes D.d1.call(1)
43+
Expect.equals(new D().d1(1), 2); //# 06: ok
44+
// Implicitly invokes D.c2.call(1)
45+
Expect.equals(new D().c2(1), 2); //# 07: ok
46+
// Implicitly invokes D.d2.call(1)
47+
Expect.equals(new D().d2(1), 2); //# 08: ok
48+
D d = new D();
49+
// Implicitly invokes d.c1.call(1)
50+
Expect.equals(d.c1(1), 2); //# 09: ok
51+
// Implicitly invokes d.d1.call(1)
52+
Expect.equals(d.d1(1), 2); //# 10: ok
53+
// Implicitly invokes d.c2.call(1)
54+
Expect.equals(d.c2(1), 2); //# 11: ok
55+
// Implicitly invokes d.d2.call(1)
56+
Expect.equals(d.d2(1), 2); //# 12: ok
57+
}

tests/language/call/method_implicit_invoke_instance_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// Implements Function which is not allowed in Dart 3.
6-
// @dart=2.19
7-
85
// Dart test program to test arithmetic operations.
96

107
import "package:expect/expect.dart";
@@ -13,7 +10,7 @@ class C1 {
1310
int call(int i) => 2 * i;
1411
}
1512

16-
class C2 implements Function {
13+
class C2 {
1714
int call(int i) => 2 * i;
1815
}
1916

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Implements Function which is not allowed in Dart 3.
6+
// @dart=2.19
7+
8+
// Dart test program to test arithmetic operations.
9+
10+
import "package:expect/expect.dart";
11+
12+
class C1 {
13+
int call(int i) => 2 * i;
14+
}
15+
16+
class C2 implements Function {
17+
int call(int i) => 2 * i;
18+
}
19+
20+
main() {
21+
C1 c1 = new C1();
22+
// Implicitly invokes c1.call(1)
23+
Expect.equals(c1(1), 2);
24+
dynamic d1 = c1;
25+
// Implicitly invokes d1.call(1)
26+
Expect.equals(d1(1), 2);
27+
C2 c2 = new C2();
28+
// Implicitly invokes c2.call(1)
29+
Expect.equals(c2(1), 2);
30+
dynamic d2 = c2;
31+
// Implicitly invokes d2.call(1)
32+
Expect.equals(d2(1), 2);
33+
// Cannot invoke with the wrong signature.
34+
c2();
35+
// ^
36+
// [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
37+
//^^
38+
// [cfe] Too few positional arguments: 1 required, 0 given.
39+
c2(3, 4);
40+
// ^
41+
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
42+
//^^^^^^
43+
// [cfe] Too many positional arguments: 1 allowed, but 2 found.
44+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// TODO(multitest): This was automatically migrated from a multitest and may
2+
// contain strange or dead code.
3+
4+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
5+
// for details. All rights reserved. Use of this source code is governed by a
6+
// BSD-style license that can be found in the LICENSE file.
7+
8+
// Implements Function which is not allowed in Dart 3.
9+
// @dart=2.19
10+
11+
// Dart test program to test arithmetic operations.
12+
13+
import "package:expect/expect.dart";
14+
15+
class C1 {
16+
int call(int i) => 2 * i;
17+
}
18+
19+
class C2 implements Function {
20+
int call(int i) => 2 * i;
21+
}
22+
23+
main() {
24+
C1 c1 = new C1();
25+
// Implicitly invokes c1.call(1)
26+
Expect.equals(c1(1), 2);
27+
dynamic d1 = c1;
28+
// Implicitly invokes d1.call(1)
29+
30+
C2 c2 = new C2();
31+
// Implicitly invokes c2.call(1)
32+
33+
dynamic d2 = c2;
34+
// Implicitly invokes d2.call(1)
35+
36+
// Cannot invoke with the wrong signature.
37+
38+
39+
}

0 commit comments

Comments
 (0)