Skip to content

Commit cae675e

Browse files
authored
#2559. Update augmenting_constructors_A01_* tests (#3388)
* #2559. Update augmenting constructors tests * Fix augmenting enums syntax * Implement review recommendations
1 parent 20a1229 commit cae675e

24 files changed

+587
-1036
lines changed

LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,65 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// @assertion It is a compile-time error if:
6-
/// - The signature of the constructor augmentation does not match the original
7-
/// constructor. It must have the same number of positional parameters, the
8-
/// same named parameters, and matching parameters must have the same type,
9-
/// optionality, and any required modifiers must match. Any initializing
10-
/// formals and super parameters must also be the same in both constructors.
6+
/// - The signature of the augmenting function does not match the signature of
7+
/// the augmented function.
118
///
129
/// @description Checks that it is a compile-time error if the signature of the
1310
/// constructor augmentation does not match the original constructor. Test wrong
1411
/// number of positional parameters.
1512
/// @author sgrekhov22@gmail.com
1613
17-
// SharedOptions=--enable-experiment=macros
18-
19-
part 'augmenting_constructors_A01_t01_lib.dart';
14+
// SharedOptions=--enable-experiment=augmentations
2015

2116
class C {
2217
C(int x);
2318
}
2419

20+
augment class C {
21+
augment C();
22+
// ^
23+
// [analyzer] unspecified
24+
// [cfe] unspecified
25+
26+
augment C(int x, int y);
27+
// ^
28+
// [analyzer] unspecified
29+
// [cfe] unspecified
30+
}
31+
2532
enum E {
2633
e0(0);
2734
const E(int x);
2835
}
2936

37+
augment enum E {
38+
;
39+
augment const E();
40+
// ^
41+
// [analyzer] unspecified
42+
// [cfe] unspecified
43+
44+
augment const E(int x, int y);
45+
// ^
46+
// [analyzer] unspecified
47+
// [cfe] unspecified
48+
}
49+
3050
extension type ET(int id) {
3151
ET.foo(this.id);
3252
}
3353

54+
augment extension type ET {
55+
augment ET.foo();
56+
// ^^^^^^
57+
// [analyzer] unspecified
58+
// [cfe] unspecified
59+
augment ET.foo(int id, int y);
60+
// ^^^^^^
61+
// [analyzer] unspecified
62+
// [cfe] unspecified
63+
}
64+
3465
main() {
3566
print(C);
3667
print(E);

LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01_lib.dart

Lines changed: 0 additions & 55 deletions
This file was deleted.

LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,102 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// @assertion It is a compile-time error if:
6-
/// - The signature of the constructor augmentation does not match the original
7-
/// constructor. It must have the same number of positional parameters, the
8-
/// same named parameters, and matching parameters must have the same type,
9-
/// optionality, and any required modifiers must match. Any initializing
10-
/// formals and super parameters must also be the same in both constructors.
6+
/// - The signature of the augmenting function does not match the signature of
7+
/// the augmented function.
118
///
129
/// @description Checks that it is a compile-time error if the signature of the
1310
/// constructor augmentation does not match the original constructor. Test wrong
14-
/// number of optional parameters.
11+
/// number of optional positional parameters.
1512
/// @author sgrekhov22@gmail.com
1613
17-
// SharedOptions=--enable-experiment=macros
18-
19-
part 'augmenting_constructors_A01_t02_lib.dart';
14+
// SharedOptions=--enable-experiment=augmentations
2015

2116
class C {
2217
C([int x = 0]);
2318
C.n({int x = 0});
2419
}
2520

21+
augment class C {
22+
augment C();
23+
// ^
24+
// [analyzer] unspecified
25+
// [cfe] unspecified
26+
27+
augment C([int x, int y]);
28+
// ^
29+
// [analyzer] unspecified
30+
// [cfe] unspecified
31+
}
32+
33+
augment class C {
34+
augment C.n();
35+
// ^^^
36+
// [analyzer] unspecified
37+
// [cfe] unspecified
38+
39+
augment C.n({int x, int y});
40+
// ^^^
41+
// [analyzer] unspecified
42+
// [cfe] unspecified
43+
}
44+
2645
enum E {
2746
e0(0);
2847
const E([int x = 0]);
2948
const E.n({int x = 0});
3049
}
3150

51+
augment enum E {
52+
;
53+
augment const E();
54+
// ^
55+
// [analyzer] unspecified
56+
// [cfe] unspecified
57+
58+
augment const E([int x, int y]);
59+
// ^
60+
// [analyzer] unspecified
61+
// [cfe] unspecified
62+
}
63+
64+
augment enum E {
65+
augment e0;
66+
augment const E.n();
67+
// ^^^
68+
// [analyzer] unspecified
69+
// [cfe] unspecified
70+
71+
augment const E.n({int x, int y});
72+
// ^^^
73+
// [analyzer] unspecified
74+
// [cfe] unspecified
75+
}
76+
3277
extension type ET(int id) {
3378
ET.foo([int x = 0]): this.id = 0;
3479
ET.baz({int x = 0}): this.id = 0;
3580
}
3681

82+
augment extension type ET {
83+
augment ET.foo();
84+
// ^^^^^^
85+
// [analyzer] unspecified
86+
// [cfe] unspecified
87+
augment ET.foo([int x, int y = 0]);
88+
// ^^^^^^
89+
// [analyzer] unspecified
90+
// [cfe] unspecified
91+
92+
augment ET.baz();
93+
// ^^^^^^
94+
// [analyzer] unspecified
95+
// [cfe] unspecified
96+
augment ET.baz({int x, int y = 0});
97+
// ^^^^^^
98+
// [analyzer] unspecified
99+
// [cfe] unspecified
100+
}
101+
37102
main() {
38103
print(C);
39104
print(E);

LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02_lib.dart

Lines changed: 0 additions & 89 deletions
This file was deleted.

LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,51 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// @assertion It is a compile-time error if:
6-
/// - The signature of the constructor augmentation does not match the original
7-
/// constructor. It must have the same number of positional parameters, the
8-
/// same named parameters, and matching parameters must have the same type,
9-
/// optionality, and any required modifiers must match. Any initializing
10-
/// formals and super parameters must also be the same in both constructors.
6+
/// - The signature of the augmenting function does not match the signature of
7+
/// the augmented function.
118
///
129
/// @description Checks that it is a compile-time error if the signature of the
1310
/// constructor augmentation does not match the original constructor. Test wrong
1411
/// names of named parameters.
1512
/// @author sgrekhov22@gmail.com
1613
17-
// SharedOptions=--enable-experiment=macros
18-
19-
part 'augmenting_constructors_A01_t03_lib.dart';
14+
// SharedOptions=--enable-experiment=augmentations
2015

2116
class C {
2217
C({int x = 0});
2318
}
2419

20+
augment class C {
21+
augment C({int y});
22+
// ^
23+
// [analyzer] unspecified
24+
// [cfe] unspecified
25+
}
26+
2527
enum E {
2628
e0;
27-
//^^
29+
const E({int x = 0});
30+
}
31+
32+
augment enum E {
33+
;
34+
augment const E({int y});
35+
// ^
2836
// [analyzer] unspecified
2937
// [cfe] unspecified
30-
const E({int x = 0});
3138
}
3239

3340
extension type ET(int id) {
3441
ET.baz({int x = 0}): this.id = 0;
3542
}
3643

44+
augment extension type ET {
45+
augment ET.baz({int y});
46+
// ^^^^^^
47+
// [analyzer] unspecified
48+
// [cfe] unspecified
49+
}
50+
3751
main() {
3852
print(C);
3953
print(E);

0 commit comments

Comments
 (0)