Skip to content

Commit

Permalink
dart-lang#2868. Add extension methods accessibility tests. Part 1. (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov authored Sep 11, 2024
1 parent 55e7fd3 commit 1432a16
Show file tree
Hide file tree
Showing 18 changed files with 491 additions and 0 deletions.
23 changes: 23 additions & 0 deletions LanguageFeatures/Extension-methods/accessibility_A01_t01.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t02.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t03.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t04.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t05.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t06.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t07.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t08.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t09.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t09_lib.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t10.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t10_lib.dart
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 LanguageFeatures/Extension-methods/accessibility_A01_t11.dart
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
}
Loading

0 comments on commit 1432a16

Please sign in to comment.