-
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 tests for augment libraries visibility{
- Loading branch information
Showing
19 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,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 Declarations in any library augmentation or the augmented library | ||
/// are visible to all of the others, including private ones. | ||
/// | ||
/// @description Checks that declarations in an augmentation are visible in a | ||
/// main library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
import augment 'defining_augmentation_A01_t01_lib.dart'; | ||
|
||
extension on C1 { | ||
String get z => "z"; | ||
} | ||
|
||
extension on _C2 { | ||
String get _z => "_z"; | ||
} | ||
|
||
extension type ET1(C1 id) {} | ||
extension type ET2(_C2 id) {} | ||
|
||
class MA1 = Object with M1; | ||
class MA2 = Object with _M2; | ||
|
||
main() { | ||
Expect.equals("y", C1().y); | ||
Expect.equals("z", C1().z); | ||
Expect.equals("m", MA1().m); | ||
Expect.equals("_y", _C2()._y); | ||
Expect.equals("_z", _C2()._z); | ||
Expect.equals("_m", MA2()._m); | ||
Expect.equals("y", ET1(C1()).id.y); | ||
Expect.equals("_y", ET2(_C2()).id._y); | ||
Expect.equals(E1.e, E1.e.instance); | ||
Expect.equals(_E2.e, _E2.e._instance); | ||
Expect.equals(42, x1); | ||
Expect.equals(42, _x2); | ||
Expect.equals(0, foo1()); | ||
Expect.equals(0, _foo2()); | ||
Expect.equals("bar", [].bar); | ||
Expect.equals("bar", MyList([]).bar); | ||
Expect.equals("_baz", [].baz); | ||
Expect.equals("_baz", _MyList([]).baz); | ||
Expect.equals(42, MyInt(42)); | ||
Expect.equals(42, _MyInt(42)); | ||
Expect.isTrue((Foo1 as dynamic) is Type); | ||
Expect.isTrue((_Foo2 as dynamic) is Type); | ||
Expect.isTrue((C1Alias as dynamic) is Type); | ||
Expect.isTrue((_C2Alias as dynamic) is Type); | ||
} |
70 changes: 70 additions & 0 deletions
70
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,70 @@ | ||
// 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 Declarations in any library augmentation or the augmented library | ||
/// are visible to all of the others, including private ones. | ||
/// | ||
/// @description Checks that declarations in an augmentation are visible in a | ||
/// main library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'defining_augmentation_A01_t01.dart'; | ||
|
||
class C1 { | ||
String get y => "y"; | ||
} | ||
|
||
mixin M1 { | ||
String get m => "m"; | ||
} | ||
|
||
enum E1 { | ||
e; | ||
|
||
E1 get instance => e; | ||
} | ||
|
||
var x1 = 42; | ||
|
||
int foo1() => 0; | ||
|
||
extension MyList on List { | ||
String get bar => "bar"; | ||
} | ||
|
||
extension type MyInt(int id) {} | ||
|
||
typedef void Foo1(); | ||
|
||
typedef C1Alias = C1; | ||
|
||
class _C2 { | ||
String get _y => "_y"; | ||
} | ||
|
||
mixin _M2 { | ||
String get _m => "_m"; | ||
} | ||
|
||
enum _E2 { | ||
e; | ||
|
||
_E2 get _instance => e; | ||
} | ||
|
||
var _x2 = 42; | ||
|
||
int _foo2() => 0; | ||
|
||
extension _MyList on List { | ||
String get baz => "_baz"; | ||
} | ||
|
||
extension type _MyInt(int id2) {} | ||
|
||
typedef void _Foo2(); | ||
|
||
typedef _C2Alias = _C2; |
77 changes: 77 additions & 0 deletions
77
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,77 @@ | ||
// 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 Declarations in any library augmentation or the augmented library | ||
/// are visible to all of the others, including private ones. | ||
/// | ||
/// @description Checks that declarations in a main library are visible in an | ||
/// augmentation library | ||
/// @author [email protected] | ||
/// @issue 55103 | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'defining_augmentation_A01_t02_lib.dart'; | ||
|
||
import '../../Utils/expect.dart'; | ||
|
||
class C1 { | ||
String get y => "y"; | ||
} | ||
|
||
mixin M1 { | ||
String get m => "m"; | ||
} | ||
|
||
enum E1 { | ||
e; | ||
|
||
E1 get instance => e; | ||
} | ||
|
||
var x1 = 42; | ||
|
||
int foo1() => 0; | ||
|
||
extension MyList on List { | ||
String get bar => "bar"; | ||
} | ||
|
||
extension type MyInt(int id) {} | ||
|
||
typedef void Foo1(); | ||
|
||
typedef C1Alias = C1; | ||
|
||
class _C2 { | ||
String get _y => "_y"; | ||
} | ||
|
||
mixin _M2 { | ||
String get _m => "_m"; | ||
} | ||
|
||
enum _E2 { | ||
e; | ||
|
||
_E2 get _instance => e; | ||
} | ||
|
||
var _x2 = 42; | ||
|
||
int _foo2() => 0; | ||
|
||
extension _MyList on List { | ||
String get baz => "_baz"; | ||
} | ||
|
||
extension type _MyInt(int id2) {} | ||
|
||
typedef void _Foo2(); | ||
|
||
typedef _C2Alias = _C2; | ||
|
||
main() { | ||
test(); | ||
} |
57 changes: 57 additions & 0 deletions
57
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,57 @@ | ||
// 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 Declarations in any library augmentation or the augmented library | ||
/// are visible to all of the others, including private ones. | ||
/// | ||
/// @description Checks that declarations in a main library are visible in an | ||
/// augmentation library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'defining_augmentation_A01_t02.dart'; | ||
|
||
import '../../Utils/expect.dart'; | ||
|
||
extension on C1 { | ||
String get z => "z"; | ||
} | ||
|
||
extension on _C2 { | ||
String get _z => "_z"; | ||
} | ||
|
||
extension type ET1(C1 id) {} | ||
extension type ET2(_C2 id) {} | ||
|
||
class MA1 = Object with M1; | ||
class MA2 = Object with _M2; | ||
|
||
test() { | ||
Expect.equals("y", C1().y); | ||
Expect.equals("z", C1().z); | ||
Expect.equals("m", MA1().m); | ||
Expect.equals("_y", _C2()._y); | ||
Expect.equals("_z", _C2()._z); | ||
Expect.equals("_m", MA2()._m); | ||
Expect.equals("y", ET1(C1()).id.y); | ||
Expect.equals("_y", ET2(_C2()).id._y); | ||
Expect.equals(E1.e, E1.e.instance); | ||
Expect.equals(_E2.e, _E2.e._instance); | ||
Expect.equals(42, x1); | ||
Expect.equals(42, _x2); | ||
Expect.equals(0, foo1()); | ||
Expect.equals(0, _foo2()); | ||
Expect.equals("bar", [].bar); | ||
Expect.equals("bar", MyList([]).bar); | ||
Expect.equals("_baz", [].baz); | ||
Expect.equals("_baz", _MyList([]).baz); | ||
Expect.equals(42, MyInt(42)); | ||
Expect.equals(42, _MyInt(42)); | ||
Expect.isTrue((Foo1 as dynamic) is Type); | ||
Expect.isTrue((_Foo2 as dynamic) is Type); | ||
Expect.isTrue((C1Alias as dynamic) is Type); | ||
Expect.isTrue((_C2Alias as dynamic) is Type); | ||
} |
22 changes: 22 additions & 0 deletions
22
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in a main library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'defining_augmentation_A02_t01_lib.dart'; | ||
|
||
main() { | ||
print(AL); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Augmentation-libraries/defining_augmentation_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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in a main library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'defining_augmentation_A02_t01.dart'; | ||
|
||
import 'augmentation_libraries_lib.dart'; | ||
|
||
class C implements AL {} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Augmentation-libraries/defining_augmentation_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,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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in a main library even if an augmentation library exports it | ||
/// @author [email protected] | ||
/// @issue 55112 | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'defining_augmentation_A02_t02_lib.dart'; | ||
|
||
main() { | ||
print(AL); | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
18 changes: 18 additions & 0 deletions
18
LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_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,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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in a main library even if an augmentation library exports it | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'defining_augmentation_A02_t02.dart'; | ||
|
||
import 'augmentation_libraries_lib.dart'; | ||
export 'augmentation_libraries_lib.dart'; |
20 changes: 20 additions & 0 deletions
20
LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_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,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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in another augmentation library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'defining_augmentation_A02_t03_lib1.dart'; | ||
import augment 'defining_augmentation_A02_t03_lib2.dart'; | ||
|
||
main() { | ||
test(); | ||
} |
17 changes: 17 additions & 0 deletions
17
LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_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,17 @@ | ||
// 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 Augmentations do not share an import scope with the main library | ||
/// or each other. The libraries one augmentation imports are visible only to | ||
/// that file. | ||
/// | ||
/// @description Checks that imports in an augmentation library are not visible | ||
/// in another augmentation library | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'defining_augmentation_A02_t03.dart'; | ||
|
||
import 'augmentation_libraries_lib.dart'; |
Oops, something went wrong.