forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#2559. Add augmented expression tests for getters
- Loading branch information
Showing
15 changed files
with
1,011 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
LanguageFeatures/Augmentation-libraries/augmented_expression_A01_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,61 @@ | ||
// 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 | ||
/// getter and evaluates to the return value. If augmenting a field with a | ||
/// getter, this will invoke the implicit getter from the augmented field. | ||
/// | ||
/// @description Checks that within an augmenting getter `augmented` invokes the | ||
/// augmented getter and evaluates it to the return value. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmented_expression_A01_t01_lib.dart'; | ||
import '../../Utils/expect.dart'; | ||
|
||
String get augmented => "Getter augmented"; | ||
|
||
String get topLevelGetter => "Original"; | ||
|
||
class C { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
mixin M { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
enum E { | ||
e1; | ||
|
||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Expect.equals("Augmented", topLevelGetter); | ||
Expect.equals("Augmented", C.staticGetter); | ||
Expect.equals("Augmented", C().instanceGetter); | ||
Expect.equals("Augmented", M.staticGetter); | ||
Expect.equals("Augmented", MA().instanceGetter); | ||
Expect.equals("Augmented", E.staticGetter); | ||
Expect.equals("Augmented", E.e1.instanceGetter); | ||
Expect.equals("Augmented", Ext.staticGetter); | ||
Expect.equals("Augmented", A().instanceGetter); | ||
} |
69 changes: 69 additions & 0 deletions
69
LanguageFeatures/Augmentation-libraries/augmented_expression_A01_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,69 @@ | ||
// 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 | ||
/// getter and evaluates to the return value. If augmenting a field with a | ||
/// getter, this will invoke the implicit getter from the augmented field. | ||
/// | ||
/// @description Checks that within an augmenting getter `augmented` invokes the | ||
/// augmented getter and evaluates it to the return value. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmented_expression_A01_t01.dart'; | ||
|
||
augment String get topLevelGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
|
||
augment class C { | ||
augment static String get staticGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static String get staticGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e1; | ||
|
||
augment static String get staticGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static String get staticGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceGetter { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
LanguageFeatures/Augmentation-libraries/augmented_expression_A01_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,59 @@ | ||
// 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 | ||
/// getter and evaluates to the return value. If augmenting a field with a | ||
/// getter, this will invoke the implicit getter from the augmented field. | ||
/// | ||
/// @description Checks that within an augmenting getter `augmented` invokes the | ||
/// augmented implicit getter and evaluates it to the return value. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmented_expression_A01_t02_lib.dart'; | ||
import '../../Utils/expect.dart'; | ||
|
||
String get augmented => "Getter augmented"; | ||
|
||
String topLevelVariable = "Original"; | ||
|
||
class C { | ||
static String staticField = "Original"; | ||
String instanceField = "Original"; | ||
} | ||
|
||
mixin M { | ||
static String staticField = "Original"; | ||
String instanceField = "Original"; | ||
} | ||
|
||
enum E { | ||
e1; | ||
|
||
static String staticField = "Original"; | ||
final String instanceField = "Original"; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static String staticField = "Original"; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
Expect.equals("Augmented", topLevelVariable); | ||
Expect.equals("Augmented", C.staticField); | ||
Expect.equals("Augmented", C().instanceField); | ||
Expect.equals("Augmented", M.staticField); | ||
Expect.equals("Augmented", MA().instanceField); | ||
Expect.equals("Augmented", E.staticField); | ||
Expect.equals("Augmented", E.e1.instanceField); | ||
Expect.equals("Augmented", Ext.staticField); | ||
} |
65 changes: 65 additions & 0 deletions
65
LanguageFeatures/Augmentation-libraries/augmented_expression_A01_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,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 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 | ||
/// getter and evaluates to the return value. If augmenting a field with a | ||
/// getter, this will invoke the implicit getter from the augmented field. | ||
/// | ||
/// @description Checks that within an augmenting getter `augmented` invokes the | ||
/// augmented implicit getter and evaluates it to the return value. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmented_expression_A01_t02.dart'; | ||
|
||
augment String get topLevelVariable { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
|
||
augment class C { | ||
augment static String get staticField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static String get staticField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e1; | ||
|
||
augment static String get staticField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
augment String get instanceField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static String get staticField { | ||
Expect.equals("Original", augmented); | ||
return "Augmented"; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
LanguageFeatures/Augmentation-libraries/augmented_expression_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,56 @@ | ||
// 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 | ||
/// getter and evaluates to the return value. If augmenting a field with a | ||
/// getter, this will invoke the implicit getter from the augmented field. | ||
/// | ||
/// @description Checks that it is a compile-time error if within an augmenting | ||
/// getter `augmented()` expression is invoked. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmented_expression_A01_t03_lib.dart'; | ||
|
||
String augmented() => "Function augmented()"; | ||
|
||
String get topLevelGetter => "Original"; | ||
|
||
class C { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
mixin M { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
enum E { | ||
e1; | ||
|
||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static String get staticGetter => "Original"; | ||
String get instanceGetter => "Original"; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
print(topLevelGetter); | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
} |
Oops, something went wrong.