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#2868. Add extension methods accessibility tests. Part 1. (d…
- Loading branch information
Showing
18 changed files
with
491 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Extension-methods/accessibility_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,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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a non-private name is accessible | ||
/// if it is imported via non-prefixed import. | ||
/// @author [email protected] | ||
import '../../Utils/expect.dart'; | ||
import 'accessibility_lib.dart'; | ||
|
||
main() { | ||
Expect.equals("StringExt", "".id1); | ||
Expect.equals("StringExt2", "".id2); | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Extension-methods/accessibility_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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a non-private name is accessible | ||
/// if it is imported via prefixed import. | ||
/// @author [email protected] | ||
import '../../Utils/expect.dart'; | ||
import 'accessibility_lib.dart' as p; | ||
|
||
main() { | ||
Expect.equals("StringExt", "".id1); | ||
Expect.equals("StringExt2", "".id2); | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Extension-methods/accessibility_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,30 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a private name or with no name | ||
/// is not accessible if a library containing its declaration is imported via | ||
/// non-prefixed import. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart'; | ||
|
||
main() { | ||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Extension-methods/accessibility_A01_t04.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,30 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a private name or with no name | ||
/// is not accessible if a library containing its declaration is imported via | ||
/// prefixed import. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart' as p; | ||
|
||
main() { | ||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Extension-methods/accessibility_A01_t05.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,36 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is imported but it's name is hidden by a `hide` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart' hide StringExt; | ||
|
||
main() { | ||
"".id1; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id2; // Ok | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Extension-methods/accessibility_A01_t06.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,37 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is imported vis prefixed import but it's name is hidden by a | ||
/// `hide` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart' as p hide StringExt; | ||
|
||
main() { | ||
"".id1; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id2; // Ok | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Extension-methods/accessibility_A01_t07.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,36 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is imported but it's name is hidden by a `show` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart' show StringExt; | ||
|
||
main() { | ||
"".id1; // Ok | ||
|
||
"".id2; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Extension-methods/accessibility_A01_t08.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,37 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is imported vis prefixed import but it's name is hidden by a | ||
/// `show` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_lib.dart' as p show StringExt; | ||
|
||
main() { | ||
"".id1; // Ok | ||
|
||
"".id2; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Extension-methods/accessibility_A01_t09.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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a non-private name is accessible | ||
/// if it is added to the export scope. | ||
/// @author [email protected] | ||
import '../../Utils/expect.dart'; | ||
import 'accessibility_A01_t09_lib.dart'; | ||
|
||
main() { | ||
Expect.equals("StringExt", "".id1); | ||
Expect.equals("StringExt2", "".id2); | ||
} |
17 changes: 17 additions & 0 deletions
17
LanguageFeatures/Extension-methods/accessibility_A01_t09_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,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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension with a non-private name is accessible | ||
/// if it is added to the export scope. | ||
/// @author [email protected] | ||
export 'accessibility_lib.dart'; |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Extension-methods/accessibility_A01_t10.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,36 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is exported but it's name is hidden by a `hide` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_A01_t10_lib.dart'; | ||
|
||
main() { | ||
"".id1; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id2; // Ok | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
17 changes: 17 additions & 0 deletions
17
LanguageFeatures/Extension-methods/accessibility_A01_t10_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,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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is exported but it's name is hidden by a `hide` combinator. | ||
/// @author [email protected] | ||
export 'accessibility_lib.dart' hide StringExt; |
36 changes: 36 additions & 0 deletions
36
LanguageFeatures/Extension-methods/accessibility_A01_t11.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,36 @@ | ||
// 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 An extension is accessible for an expression if it is declared in | ||
/// the current library, or if there is a non-deferred `import` declaration in | ||
/// the current library which imports a library with the extension in its export | ||
/// scope, where the name of the extension is not private, and the declaration | ||
/// is not hidden by a `hide` combinator mentioning the extension name, or a | ||
/// `show` combinator not mentioning the name, on the import. This includes | ||
/// (non-deferred) imports with a prefix. | ||
/// | ||
/// @description Check that an extension is not accessible if a library where it | ||
/// is declared is exported but it's name is hidden by a `show` combinator. | ||
/// @author [email protected] | ||
import 'accessibility_A01_t11_lib.dart'; | ||
|
||
main() { | ||
"".id1; // Ok | ||
|
||
"".id2; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id3; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
"".id4; | ||
// ^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
Oops, something went wrong.