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 merge order and augmenting declarations tests
- Loading branch information
Showing
12 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
LanguageFeatures/Augmentation-libraries/augmenting_declarations_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,22 @@ | ||
// 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: | ||
/// - An augmenting declaration has no corresponding original declaration to | ||
/// apply to. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// declaration has no corresponding original declaration to apply to | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment class C {} | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(C); | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Augmentation-libraries/augmenting_declarations_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,23 @@ | ||
// 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: | ||
/// - An augmenting declaration has no corresponding original declaration to | ||
/// apply to. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// declaration has no corresponding original declaration to apply to | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment void foo() {} | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
void foo() {} | ||
print(foo); | ||
} |
25 changes: 25 additions & 0 deletions
25
LanguageFeatures/Augmentation-libraries/augmenting_declarations_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,25 @@ | ||
// 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: | ||
/// - An augmenting declaration has no corresponding original declaration to | ||
/// apply to. | ||
/// | ||
/// @description Checks that it is not an error if an augmenting | ||
/// declaration do has a corresponding original declaration to apply to | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
|
||
augment class C { | ||
int get baz => 42; | ||
} | ||
|
||
class C {} | ||
|
||
main() { | ||
Expect.equals(42, C().baz); | ||
} |
25 changes: 25 additions & 0 deletions
25
LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_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,25 @@ | ||
// 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: | ||
/// ... | ||
/// - An augmenting declaration appears in a library before the library where | ||
/// the original declaration occurs, according to merge order. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// declaration appears before non-augmenting one. Test augmented declaration in | ||
/// a main library | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_declarations_A02_t01_lib.dart'; | ||
|
||
/**/augment class C {} | ||
// ^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
main() { | ||
print(C); | ||
} |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_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 It is a compile-time error if: | ||
/// ... | ||
/// - An augmenting declaration appears in a library before the library where | ||
/// the original declaration occurs, according to merge order. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// declaration appears before non-augmenting one. Test augmented declaration in | ||
/// a main library | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'augmenting_declarations_A02_t01.dart'; | ||
|
||
class C {} |
21 changes: 21 additions & 0 deletions
21
LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_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,21 @@ | ||
// 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: | ||
/// ... | ||
/// - An augmenting declaration appears in a library before the library where | ||
/// the original declaration occurs, according to merge order. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// declaration appears before non-augmenting one. Test augmented declaration in | ||
/// an augment library | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_declarations_A02_t02_lib1.dart'; | ||
|
||
main() { | ||
print(C); | ||
} |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t02_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,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 non-augmenting declaration must appear first before it can be | ||
/// augmented. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'augmenting_declarations_A02_t02.dart'; | ||
import augment 'augmenting_declarations_A02_t02_lib2.dart'; | ||
|
||
/**/augment class C {} | ||
// ^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified |
15 changes: 15 additions & 0 deletions
15
LanguageFeatures/Augmentation-libraries/augmenting_declarations_A02_t02_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,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. | ||
|
||
/// @assertion A non-augmenting declaration must appear first before it can be | ||
/// augmented. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'augmenting_declarations_A02_t02_lib1.dart'; | ||
|
||
class C {} |
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Augmentation-libraries/merge_order_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,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 The merge order is defined as a depth-first pre-order traversal | ||
/// of the import augment directives starting at the main library. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 55154 | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'merge_order_A01_t01_lib1.dart'; | ||
import augment 'merge_order_A01_t01_lib3.dart'; | ||
|
||
String log = ""; | ||
|
||
void logger() { | ||
log += "main;"; | ||
} | ||
|
||
main() { | ||
logger(); | ||
Expect.equals("main;lib1;lib2;lib3;", log); | ||
} |
20 changes: 20 additions & 0 deletions
20
LanguageFeatures/Augmentation-libraries/merge_order_A01_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,20 @@ | ||
// 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 merge order is defined as a depth-first pre-order traversal | ||
/// of the import augment directives starting at the main library. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'merge_order_A01_t01.dart'; | ||
|
||
import augment 'merge_order_A01_t01_lib2.dart'; | ||
|
||
augment void logger() { | ||
augmented(); | ||
log += "lib1;"; | ||
} |
18 changes: 18 additions & 0 deletions
18
LanguageFeatures/Augmentation-libraries/merge_order_A01_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,18 @@ | ||
// 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 merge order is defined as a depth-first pre-order traversal | ||
/// of the import augment directives starting at the main library. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'merge_order_A01_t01_lib1.dart'; | ||
|
||
augment void logger() { | ||
augmented(); | ||
log += "lib2;"; | ||
} |
18 changes: 18 additions & 0 deletions
18
LanguageFeatures/Augmentation-libraries/merge_order_A01_t01_lib3.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,18 @@ | ||
// 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 merge order is defined as a depth-first pre-order traversal | ||
/// of the import augment directives starting at the main library. | ||
/// | ||
/// @description Checks the merge order of augment libraries | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
library augment 'merge_order_A01_t01.dart'; | ||
|
||
augment void logger() { | ||
augmented(); | ||
log += "lib3;"; | ||
} |