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 function
- Loading branch information
Showing
5 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
LanguageFeatures/Augmentation-libraries/augmented_expression_A04_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,60 @@ | ||
// 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 functions: When augmenting a function, augmented refers to the | ||
/// augmented function. Tear offs are not allowed, so this function must | ||
/// immediately be invoked. | ||
/// | ||
/// @description Checks that it is a compile-time error to tear-off `augmented` | ||
/// expression inside of an augmenting function | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmented_expression_A04_t01_lib1.dart'; | ||
import augment 'augmented_expression_A04_t01_lib2.dart'; | ||
|
||
const augmented = "Augmented constant, should not be used"; | ||
|
||
void topLevelFunction() {} | ||
|
||
class C { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
final augmented = "C.augmented, should not be used"; | ||
} | ||
|
||
mixin M { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
final augmented = "M.augmented, should not be used"; | ||
} | ||
|
||
enum E { | ||
e1; | ||
|
||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
final augmented = "E.augmented, should not be used"; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
final augmented = "Ext.augmented, should not be used"; | ||
} | ||
|
||
main() { | ||
print(topLevelFunction); | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
} |
88 changes: 88 additions & 0 deletions
88
LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t01_lib1.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,88 @@ | ||
// 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 functions: When augmenting a function, augmented refers to the | ||
/// augmented function. Tear offs are not allowed, so this function must | ||
/// immediately be invoked. | ||
/// | ||
/// @description Checks that it is a compile-time error to tear-off `augmented` | ||
/// expression inside of an augmenting function | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmented_expression_A04_t01.dart'; | ||
|
||
augment void topLevelFunction() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment class C { | ||
augment static void staticMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static void staticMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e1; | ||
|
||
augment static void staticMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static void staticMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var f = augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t01_lib2.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,106 @@ | ||
// 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 functions: When augmenting a function, augmented refers to the | ||
/// augmented function. Tear offs are not allowed, so this function must | ||
/// immediately be invoked. | ||
/// | ||
/// @description Checks that it is a compile-time error to tear-off `augmented` | ||
/// expression inside of an augmenting function | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmented_expression_A04_t01.dart'; | ||
|
||
augment void topLevelFunction() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment class C { | ||
augment static void staticMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
augment void instanceMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static void staticMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
augment void instanceMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e1; | ||
|
||
augment static void staticMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
augment void instanceMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static void staticMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
augment void instanceMethod() { | ||
var f = () { | ||
augmented.toString(); | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
LanguageFeatures/Augmentation-libraries/augmented_expression_A04_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,53 @@ | ||
// 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 functions: When augmenting a function, augmented refers to the | ||
/// augmented function. Tear offs are not allowed, so this function must | ||
/// immediately be invoked. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a local | ||
/// variable named `augmented` inside of an augmenting function | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmented_expression_A04_t02_lib.dart'; | ||
|
||
void topLevelFunction() {} | ||
|
||
class C { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
} | ||
|
||
mixin M { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
} | ||
|
||
enum E { | ||
e1; | ||
|
||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static void staticMethod() {} | ||
void instanceMethod() {} | ||
} | ||
|
||
main() { | ||
print(topLevelFunction); | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
} |
88 changes: 88 additions & 0 deletions
88
LanguageFeatures/Augmentation-libraries/augmented_expression_A04_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,88 @@ | ||
// 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 functions: When augmenting a function, augmented refers to the | ||
/// augmented function. Tear offs are not allowed, so this function must | ||
/// immediately be invoked. | ||
/// | ||
/// @description Checks that it is a compile-time error to tear-off `augmented` | ||
/// expression inside of an augmenting function | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmented_expression_A04_t02.dart'; | ||
|
||
augment void topLevelFunction() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment class C { | ||
augment static void staticMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static void staticMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e1; | ||
|
||
augment static void staticMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static void staticMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
augment void instanceMethod() { | ||
var augmented; | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} |