-
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
- Loading branch information
Showing
14 changed files
with
373 additions
and
154 deletions.
There are no files selected for viewing
74 changes: 0 additions & 74 deletions
74
Language/Libraries_and_Scripts/Imports/deferred_import_t01.dart
This file was deleted.
Oops, something went wrong.
79 changes: 0 additions & 79 deletions
79
Language/Libraries_and_Scripts/Imports/deferred_import_t02.dart
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Language/Libraries_and_Scripts/Imports/same_name_prefix_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) 2023, 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 the prefix used in a deferred | ||
/// import is also used as the prefix of another import clause | ||
/// | ||
/// @description Checks that it is a compile-time error if the prefix used in a | ||
/// deferred import is also used as the prefix of another deferred import clause | ||
/// @author [email protected] | ||
import 'static_type_lib.dart' deferred as p; | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
|
||
import 'syntax_lib.dart' deferred as p; | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
p.loadLibrary(); | ||
} |
22 changes: 22 additions & 0 deletions
22
Language/Libraries_and_Scripts/Imports/same_name_prefix_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,22 @@ | ||
// Copyright (c) 2023, 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 the prefix used in a deferred | ||
/// import is also used as the prefix of another import clause | ||
/// | ||
/// @description Checks that it is a compile-time error if the prefix used in a | ||
/// deferred import is also used as the prefix of another immediate import | ||
/// clause | ||
/// @author [email protected] | ||
import 'static_type_lib.dart' deferred as p; | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
import 'syntax_lib.dart' as p; | ||
|
||
main() { | ||
p.loadLibrary(); | ||
} |
20 changes: 20 additions & 0 deletions
20
Language/Libraries_and_Scripts/Imports/same_name_prefix_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,20 @@ | ||
// Copyright (c) 2023, 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 the prefix used in a deferred | ||
/// import is also used as the prefix of another import clause | ||
/// | ||
/// @description Checks that it is not an error if the prefix used in a | ||
/// non-deferred import is also used as the prefix of another immediate import | ||
/// clause | ||
/// @author [email protected] | ||
import '../../../Utils/expect.dart'; | ||
import 'static_type_lib.dart' as p; | ||
import 'syntax_lib.dart' as p; | ||
|
||
main() { | ||
Expect.equals(1, p.someFunc()); // from static_type_lib.dart | ||
Expect.equals("hide", p.hide); // from syntax_lib.dart | ||
} |
23 changes: 23 additions & 0 deletions
23
Language/Libraries_and_Scripts/Imports/same_name_prefix_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) 2023, 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 the prefix used in a deferred | ||
/// import is also used as the prefix of another import clause | ||
/// | ||
/// @description Checks that it is not an error if two deferred libraries with | ||
/// two different prefixes are imported | ||
/// @author [email protected] | ||
import '../../../Utils/expect.dart'; | ||
import 'static_type_lib.dart' deferred as p1; | ||
import 'syntax_lib.dart' deferred as p2; | ||
|
||
main() async { | ||
asyncStart(); | ||
await p1.loadLibrary(); | ||
await p2.loadLibrary(); | ||
Expect.equals(1, p1.someFunc()); // from static_type_lib.dart | ||
Expect.equals("hide", p2.hide); // from syntax_lib.dart | ||
asyncEnd(); | ||
} |
32 changes: 32 additions & 0 deletions
32
Language/Libraries_and_Scripts/Imports/semantics_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,32 @@ | ||
// Copyright (c) 2023, 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 Let Ii be an import directive that refers to a URI via the string | ||
/// si. The semantics of Ii is specified as follows: | ||
/// Case ⟨Semantics of deferred imports⟩. If Ii is a deferred import with prefix | ||
/// p, a binding of p to a deferred prefix run-time namespace NSdeferred is | ||
/// present in the library namespace of the current library L. Let NSimport,i be | ||
/// the namespace imported from the library specified by Ii. | ||
/// NSdeferred then has the following bindings: | ||
/// • The name loadLibrary is bound to a function with signature | ||
/// Future<void> loadLibrary(). This function returns a future f. When called, | ||
/// the function causes an immediate import I′ to be executed at some future | ||
/// time, where I′ is derived from Ii by eliding the word deferred and adding | ||
/// a hide loadLibrary combinator clause. The execution of the immediate | ||
/// import may fail for implementation specific reasons. For instance, I′ | ||
/// imports a different library than the one that the specified URI referred | ||
/// to at compiletime; or an OS level file read error occurs; etc. We say that | ||
/// the invocation of loadLibrary succeeds if f completes with a value, and | ||
/// that the invocation fails if f completes with an error. | ||
/// | ||
/// @description Checks that static type of `loadLibrary` is | ||
/// `Future<void> Function()` | ||
/// @author [email protected] | ||
import "static_type_lib.dart" deferred as p; | ||
import "../../../Utils/static_type_helper.dart"; | ||
|
||
main() { | ||
p.loadLibrary.expectStaticType<Exactly<Future<void> Function()>>(); | ||
} |
49 changes: 49 additions & 0 deletions
49
Language/Libraries_and_Scripts/Imports/semantics_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,49 @@ | ||
// Copyright (c) 2011, 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 Let Ii be an import directive that refers to a URI via the string | ||
/// si. The semantics of Ii is specified as follows: | ||
/// Case ⟨Semantics of deferred imports⟩. If Ii is a deferred import with prefix | ||
/// p, a binding of p to a deferred prefix run-time namespace NSdeferred is | ||
/// present in the library namespace of the current library L. Let NSimport,i be | ||
/// the namespace imported from the library specified by Ii. | ||
/// NSdeferred then has the following bindings: | ||
/// • The name loadLibrary is bound to a function with signature | ||
/// Future<void> loadLibrary(). This function returns a future f. When called, | ||
/// the function causes an immediate import I′ to be executed at some future | ||
/// time, where I′ is derived from Ii by eliding the word deferred and adding | ||
/// a hide loadLibrary combinator clause. The execution of the immediate | ||
/// import may fail for implementation specific reasons. For instance, I′ | ||
/// imports a different library than the one that the specified URI referred | ||
/// to at compiletime; or an OS level file read error occurs; etc. We say that | ||
/// the invocation of loadLibrary succeeds if f completes with a value, and | ||
/// that the invocation fails if f completes with an error. | ||
/// | ||
/// @description Checks that call of `loadLibrary` causes an immediate import of | ||
/// the deferred library | ||
/// @author [email protected] | ||
import "../../../Utils/expect.dart"; | ||
import "static_type_lib.dart" deferred as p; | ||
|
||
void testLoaded() { | ||
Expect.equals(1, p.someFunc()); | ||
Expect.equals(3, p.someVar); | ||
Expect.equals(2, p.someGetter); | ||
p.someSetter = 1; | ||
p.Func; | ||
Expect.isTrue(p.loadLibrary() is Future<void>); | ||
Expect.runtimeIsType<Future<void>>(p.loadLibrary()); | ||
} | ||
|
||
main() { | ||
asyncStart(); | ||
p.loadLibrary().then((v) { | ||
testLoaded(); | ||
asyncEnd(); | ||
}, | ||
onError: (e) { | ||
Expect.fail("Library should be loaded"); | ||
}); | ||
} |
39 changes: 39 additions & 0 deletions
39
Language/Libraries_and_Scripts/Imports/semantics_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,39 @@ | ||
// Copyright (c) 2011, 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 Let Ii be an import directive that refers to a URI via the string | ||
/// si. The semantics of Ii is specified as follows: | ||
/// Case ⟨Semantics of deferred imports⟩. If Ii is a deferred import with prefix | ||
/// p, a binding of p to a deferred prefix run-time namespace NSdeferred is | ||
/// present in the library namespace of the current library L. Let NSimport,i be | ||
/// the namespace imported from the library specified by Ii. | ||
/// NSdeferred then has the following bindings: | ||
/// ... | ||
/// • For every top level function f named id in NSimport,i, a corresponding | ||
/// function named id with the same signature as f. Calling the function | ||
/// results in a dynamic error that occurs before any actual arguments are | ||
/// evaluated. Closurizing the function also results in a dynamic error. | ||
/// • For every top level getter g named id in NSimport,i, a corresponding | ||
/// getter named id with the same signature as g. Calling the getter results | ||
/// in a dynamic error. | ||
/// • For every top level setter s named id= in NSimport,i, a corresponding | ||
/// setter named id= with the same signature as s. Calling the setter results | ||
/// in a dynamic error that occurs before the actual argument is evaluated. | ||
/// | ||
/// @description Checks that for every top-level declaration in the imported | ||
/// library a corresponding declaration with the same name created in the | ||
/// current library. Calling the imported name results in a runtime error. | ||
/// @Issue 33118 | ||
/// @issue 42491 | ||
/// @author [email protected] | ||
import "../../../Utils/expect.dart"; | ||
import "static_type_lib.dart" deferred as p; | ||
|
||
main() { | ||
Expect.throws(() { p.someFunc(); }, (e) => e is NoSuchMethodError); | ||
Expect.throws(() { p.someGetter; }, (e) => e is NoSuchMethodError); | ||
Expect.throws(() { p.someSetter = 2; }, (e) => e is NoSuchMethodError); | ||
Expect.throws(() { p.Func; }, (e) => e is NoSuchMethodError); | ||
} |
Oops, something went wrong.