-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add augmenting types tests. Part 6
- Loading branch information
Showing
17 changed files
with
550 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
LanguageFeatures/Augmentation-libraries/augmentation_libraries_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @description Common library for augmentation libraries tests | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augmentation_libraries_lib; | ||
|
||
class AL {} | ||
|
||
final class FinalClass {} | ||
|
||
base class BaseClass {} |
26 changes: 26 additions & 0 deletions
26
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class augment may specify `extends` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'augmenting_types_A06_t01_lib.dart'; | ||
|
||
class A {} | ||
|
||
class C {} | ||
|
||
main() { | ||
Expect.isTrue(C() is A); | ||
} |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t01_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class augment may specify `extends` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A06_t01.dart'; | ||
|
||
augment class C extends A {} |
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that it is a compile-time error if a class augment | ||
/// specifies a final class in an `extends` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_types_A06_t02_lib.dart'; | ||
|
||
class A {} | ||
|
||
class C {} | ||
|
||
main() { | ||
print(A); | ||
print(C); | ||
} |
29 changes: 29 additions & 0 deletions
29
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t02_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that it is a compile-time error if a class augment | ||
/// specifies a final class in an `extends` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A06_t02.dart'; | ||
import 'augmentation_libraries_lib.dart'; | ||
|
||
augment class A extends FinalClass {} | ||
// ^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
augment class C extends String {} | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified |
46 changes: 46 additions & 0 deletions
46
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class, extension type, mixin and enum augment may | ||
/// specify `implements` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'augmenting_types_A06_t03_lib.dart'; | ||
|
||
interface class I { | ||
String get id => "I"; | ||
} | ||
|
||
class C {} | ||
|
||
extension type ET(I _) {} | ||
|
||
mixin M {} | ||
|
||
enum E { | ||
e1; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
I c = C(); | ||
I et = ET(I()); | ||
I m = MA(); | ||
I e = E.e1; | ||
Expect.equals("C", c.id); | ||
Expect.equals("I", et.id); | ||
Expect.equals("M", m.id); | ||
Expect.equals("E", e.id); | ||
} |
33 changes: 33 additions & 0 deletions
33
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t03_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class, extension type, mixin and enum augment may | ||
/// specify `implements` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A06_t03.dart'; | ||
|
||
augment class C implements I { | ||
String get id => "C"; | ||
} | ||
|
||
augment extension type ET(I _) implements I {} | ||
|
||
augment mixin M implements I { | ||
String get id => "M"; | ||
} | ||
|
||
augment enum E implements I { | ||
augment e1; | ||
String get id => "E"; | ||
} |
65 changes: 65 additions & 0 deletions
65
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t04.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class, extension type, mixin and enum augment may | ||
/// specify an additional `implements` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'augmenting_types_A06_t04_lib.dart'; | ||
|
||
abstract class I0 { | ||
String get id0; | ||
} | ||
|
||
class I1 impelements I0 { | ||
String get id0 => "I1"; | ||
String get id1 => "I1"; | ||
} | ||
|
||
class C implements I1 { | ||
String get id1 => "C"; | ||
} | ||
|
||
mixin M implements I1 { | ||
String get id1 => "M"; | ||
} | ||
|
||
extension type ET(I1 _) implements I1 {} | ||
|
||
enum E implements I1 { | ||
e1; | ||
String get id1 => "E"; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
I1 c1 = C(); | ||
I1 et1 = ET(I1()); | ||
I1 m1 = MA(); | ||
I1 e1 = E.e1; | ||
Expect.equals("C", c1.id1); | ||
Expect.equals("I1", et1.id1); | ||
Expect.equals("M", m1.id1); | ||
Expect.equals("E", e1.id1); | ||
|
||
I2 c2 = C(); | ||
I2 et2 = ET(I1()); | ||
I2 m2 = MA(); | ||
I2 e2 = E.e1; | ||
Expect.equals("I2 from C", c2.id2); | ||
Expect.equals("I0 from ET", et2.id0); | ||
Expect.equals("I2 from M", m2.id2); | ||
Expect.equals("I2 from E", e2.id2); | ||
} |
43 changes: 43 additions & 0 deletions
43
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t04_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that a class, extension type, mixin and enum augment may | ||
/// specify an additional `implements` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A06_t04.dart'; | ||
|
||
interface class I2 { | ||
String id2 => "I2"; | ||
} | ||
|
||
interface class I3 extends I1 { | ||
String id2 => "I2"; | ||
} | ||
|
||
augment class C implements I2 { | ||
String get id2 => "I2 from C"; | ||
} | ||
|
||
extension type ET(I1 _) implements I0 { | ||
String get id0 => "I0 from ET"; | ||
} | ||
|
||
augment mixin M implements I2 { | ||
String get id2 => "I2 from M"; | ||
} | ||
|
||
augment enum E implements I2 { | ||
augment e1; | ||
String get id2 => "I2 from E"; | ||
} |
42 changes: 42 additions & 0 deletions
42
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t05.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that it is a compile-time error if a class, mixin or | ||
/// enum augment specifies `implements` clause but doesn't implement this | ||
/// interface | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_types_A06_t05_lib.dart'; | ||
|
||
interface class I { | ||
String get id => "I"; | ||
} | ||
|
||
class C {} | ||
|
||
mixin M {} | ||
|
||
enum E { | ||
e1; | ||
} | ||
|
||
class MA = Object with M; | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(C); | ||
print(MA); | ||
print(E); | ||
} |
33 changes: 33 additions & 0 deletions
33
LanguageFeatures/Augmentation-libraries/augmenting_types_A06_t05_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion A class, enum, extension type, or mixin augmentation may specify | ||
/// extends, implements, on, and with clauses (when generally supported). The | ||
/// types in these clauses are appended to the original declarations clauses of | ||
/// the same kind, and if that clause did not exist previously then it is added | ||
/// with the new types. All regular rules apply after this appending process, so | ||
/// you cannot have multiple extends on a class, or an on clause on an enum, etc | ||
/// | ||
/// @description Checks that it is a compile-time error if a class, extension | ||
/// type, mixin or enum augment specifies `implements` clause but doesn't | ||
/// implement this interface | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A06_t05.dart'; | ||
|
||
augment class C implements I {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
augment mixin M implements I {} | ||
|
||
augment enum E implements I { | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment e1; | ||
} |
Oops, something went wrong.