-
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 more augmenting types tests
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Augmentation-libraries/augmenting_types_A01_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,37 @@ | ||
// 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 It is a compile-time error if: | ||
/// | ||
/// - The augmenting type and corresponding type are not the same kind: class, | ||
/// mixin, enum, or extension. You can't augment a class with a mixin, etc. | ||
/// | ||
/// @description Checks that it is not an error if an augmenting type and the | ||
/// corresponding type are the same kind. Test type aliases | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'augmenting_types_A01_t03_lib.dart'; | ||
|
||
class C {} | ||
|
||
mixin M {} | ||
|
||
enum E {e1;} | ||
|
||
typedef CAlias = C; | ||
typedef MAlias = M; | ||
typedef EAlias = E; | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Expect.equals("C", C().foo()); | ||
Expect.equals("C", CAlias().foo()); | ||
Expect.equals("M", MA().foo()); | ||
Expect.equals("E", E.e1.foo()); | ||
Expect.equals("E", EAlias.e1.foo()); | ||
} |
29 changes: 29 additions & 0 deletions
29
LanguageFeatures/Augmentation-libraries/augmenting_types_A01_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,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 It is a compile-time error if: | ||
/// | ||
/// - The augmenting type and corresponding type are not the same kind: class, | ||
/// mixin, enum, or extension. You can't augment a class with a mixin, etc. | ||
/// | ||
/// @description Checks that it is not an error if an augmenting type and the | ||
/// corresponding type are the same kind. Test type aliases | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A01_t03.dart'; | ||
|
||
augment class CAlias { | ||
String foo() => "C"; | ||
} | ||
|
||
augment mixin MAlias { | ||
String foo() => "M"; | ||
} | ||
|
||
augment enum EAlias { | ||
augment e1; | ||
String foo() => "E"; | ||
} |