-
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 metadata tests. Part 1.
- Loading branch information
Showing
8 changed files
with
1,267 additions
and
0 deletions.
There are no files selected for viewing
197 changes: 197 additions & 0 deletions
197
LanguageFeatures/Augmentation-libraries/augmented_expression_A01_t28.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,197 @@ | ||
// 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 The exact result of an `augmented` expression depends on what is | ||
/// being augmented, but it generally follows the same rules as any normal | ||
/// identifier: | ||
/// - Augmenting getters: Within an augmenting getter `augmented` invokes the | ||
/// augmented getter and evaluates to its return value. If augmenting a | ||
/// variable with a getter, this will invoke the implicitly induced getter | ||
/// from the augmented variable declaration. | ||
/// | ||
/// @description Checks that it is a compile-time error if in an augmenting | ||
/// scope an augmenting getter has a metadata named `augmented`. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
class augmented { | ||
const augmented(); | ||
} | ||
|
||
@augmented() | ||
String get topLevelGetter => "Original"; | ||
|
||
@augmented() | ||
augment String get topLevelGetter; | ||
|
||
class C { | ||
@augmented() | ||
static String get staticGetter1 => "Original"; | ||
@augmented() | ||
String get instanceGetter1 => "Original"; | ||
|
||
@augmented() | ||
augment static String get staticGetter1; | ||
@augmented() | ||
augment String get instanceGetter1; | ||
} | ||
|
||
augment class C { | ||
@augmented() augment static String get staticGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() static String get staticGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() augment String get instanceGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() String get instanceGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M { | ||
@augmented() | ||
static String get staticGetter1 => "Original"; | ||
@augmented() | ||
String get instanceGetter1 => "Original"; | ||
|
||
@augmented() | ||
augment static String get staticGetter1; | ||
@augmented() | ||
augment String get instanceGetter1; | ||
} | ||
|
||
augment mixin M { | ||
@augmented() augment static String get staticGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() static String get staticGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() augment String get instanceGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() String get instanceGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
enum E { | ||
e0; | ||
|
||
@augmented() | ||
static String get staticGetter1 => "Original"; | ||
@augmented() | ||
String get instanceGetter1 => "Original"; | ||
|
||
@augmented() | ||
augment static String get staticGetter1; | ||
@augmented() | ||
augment String get instanceGetter1; | ||
} | ||
|
||
augment enum E { | ||
e1; | ||
|
||
@augmented() augment static String get staticGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() static String get staticGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() augment String get instanceGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() String get instanceGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
@augmented() | ||
static String get staticGetter1 => "Original"; | ||
@augmented() | ||
String get instanceGetter1 => "Original"; | ||
|
||
@augmented() | ||
augment static String get staticGetter1; | ||
@augmented() | ||
augment String get instanceGetter1; | ||
} | ||
|
||
augment extension Ext { | ||
@augmented() augment static String get staticGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() static String get staticGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() augment String get instanceGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() String get instanceGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
extension type ET(int _) { | ||
@augmented() | ||
static String get staticGetter1 => "Original"; | ||
@augmented() | ||
String get instanceGetter1 => "Original"; | ||
|
||
@augmented() | ||
augment static String get staticGetter1; | ||
@augmented() | ||
augment String get instanceGetter1; | ||
} | ||
|
||
augment extension type ET { | ||
@augmented() augment static String get staticGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() static String get staticGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() augment String get instanceGetter1; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented() String get instanceGetter2 => "Augmented"; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
topLevelGetter; | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
print(ET); | ||
} |
196 changes: 196 additions & 0 deletions
196
LanguageFeatures/Augmentation-libraries/augmented_expression_A02_t26.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,196 @@ | ||
// 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 The exact result of an `augmented` expression depends on what is | ||
/// being augmented, but it generally follows the same rules as any normal | ||
/// identifier: | ||
/// ... | ||
/// - Augmenting setters: Within an augmenting setter `augmented` must be | ||
/// followed by an `=` and will directly invoke the augmented setter. If | ||
/// augmenting a variable with a setter, this will invoke the implicitly | ||
/// induced setter from the augmented variable declaration. | ||
/// | ||
/// @description Checks that it is a compile-time error if in an augmenting | ||
/// scope an augmenting setter has a metadata named `augmented`. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
const augmented = 0; | ||
|
||
@augmented | ||
void set topLevelSetter(String value) {} | ||
|
||
@augmented | ||
augment void set topLevelSetter(String value) {} | ||
|
||
class C { | ||
@augmented | ||
static void set staticSetter1(String value) {} | ||
@augmented | ||
void set instanceSetter1(String value) {} | ||
|
||
@augmented | ||
augment static void set staticSetter1(String value); | ||
@augmented | ||
augment void set instanceSetter1(String value); | ||
} | ||
|
||
augment class C { | ||
@augmented augment static void set staticSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented static void set staticSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented augment void set instanceSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented void set instanceSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
mixin M { | ||
@augmented | ||
static void set staticSetter1(String value) {} | ||
@augmented | ||
void set instanceSetter1(String value) {} | ||
|
||
@augmented | ||
augment static void set staticSetter1(String value); | ||
@augmented | ||
augment void set instanceSetter1(String value); | ||
} | ||
|
||
augment mixin M { | ||
@augmented augment static void set staticSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented static void set staticSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented augment void set instanceSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented void set instanceSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
enum E { | ||
e0; | ||
|
||
@augmented | ||
static void set staticSetter1(String value) {} | ||
@augmented | ||
void set instanceSetter1(String value) {} | ||
|
||
@augmented | ||
augment static void set staticSetter1(String value); | ||
@augmented | ||
augment void set instanceSetter1(String value); | ||
} | ||
|
||
augment enum E { | ||
e1; | ||
|
||
@augmented augment static void set staticSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented static void set staticSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented augment void set instanceSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented void set instanceSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
@augmented | ||
static void set staticSetter1(String value) {} | ||
@augmented | ||
void set instanceSetter1(String value) {} | ||
|
||
@augmented | ||
augment static void set staticSetter1(String value); | ||
@augmented | ||
augment void set instanceSetter1(String value); | ||
} | ||
|
||
augment extension Ext { | ||
@augmented augment static void set staticSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented static void set staticSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented augment void set instanceSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented void set instanceSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
extension type ET(int _) { | ||
@augmented | ||
static void set staticSetter1(String value) {} | ||
@augmented | ||
void set instanceSetter1(String value) {} | ||
|
||
@augmented | ||
augment static void set staticSetter1(String value); | ||
@augmented | ||
augment void set instanceSetter1(String value); | ||
} | ||
|
||
augment extension type ET { | ||
@augmented augment static void set staticSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented static void set staticSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented augment void set instanceSetter1(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
@augmented void set instanceSetter2(String value) {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
topLevelSetter = "1"; | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
print(ET); | ||
} |
Oops, something went wrong.