Skip to content

Commit

Permalink
Fix tests according to the new understanding of the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Sep 5, 2024
1 parent 9a3b1eb commit 9adc17e
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ part of 'scope_A03_t01.dart';
import 'scope_lib1.dart' as l1;
import 'scope_lib2.dart' as l2;

part 'scope_A03_t01_part2.dart'
part 'scope_A03_t01_part2.dart';

testPart1() {
// From scope_lib1.dart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ part of 'scope_A03_t01_part1.dart';
import 'scope_lib1.dart' as l3;
import 'scope_lib2.dart' as l4;

part 'scope_A03_t01_part2.dart'
part 'scope_A03_t01_part2.dart';

testPart2() {
// From scope_lib1.dart
Expand Down
26 changes: 0 additions & 26 deletions LanguageFeatures/Parts-with-imports/scope_A03_t03.dart

This file was deleted.

29 changes: 0 additions & 29 deletions LanguageFeatures/Parts-with-imports/scope_A03_t03_part1.dart

This file was deleted.

27 changes: 0 additions & 27 deletions LanguageFeatures/Parts-with-imports/scope_A03_t03_part2.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ part of 'scope_A04_t01.dart';

import 'scope_lib1.dart' as l;

part 'scope_A04_t01_part2.dart'
part 'scope_A04_t01_part2.dart';

testPart1() {
// From scope_lib1.dart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ part of 'scope_A04_t01_part1.dart';

import 'scope_lib2.dart' as l;

part 'scope_A04_t01_part2.dart'
part 'scope_A04_t01_part2.dart';

testPart2() {
// From scope_lib1.dart
Expand Down
50 changes: 25 additions & 25 deletions LanguageFeatures/Parts-with-imports/scope_A05_t01_part1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@

part of 'scope_A05_t01.dart';

import 'scope_lib1.dart' deferred as l;
import 'scope_lib1.dart' deferred as l1;

part 'scope_A05_t01_part2.dart'
part 'scope_A05_t01_part2.dart';

testPart1() async {
Expect.throws(() {print(l.libVar);});
Expect.throws(() {print(l.libGetter);});
Expect.throws(() {l.libSetter = "x";});
Expect.throws(() {print(l.libFunc);});
Expect.throws(() {print(l.LibClass.id);});
Expect.throws(() {print(l.LibMixin.id);});
Expect.throws(() {print(l.LibEnum.id);});
Expect.throws(() {print(l.LibExt.id);});
Expect.throws(() {print(l.LibET.id);});

await l.loadLibrary();

Expect.equals("scope_lib1 libVar", l.libVar);
Expect.equals("scope_lib1 libGetter", l.libGetter);
l.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l.libFunc);
Expect.equals("scope_lib1 LibClass", l.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l.LibExt.id);
Expect.equals("scope_lib1 LibET", l.LibET.id);

await l.loadLibrary(); // Not an error
Expect.throws(() {print(l1.libVar);});
Expect.throws(() {print(l1.libGetter);});
Expect.throws(() {l1.libSetter = "x";});
Expect.throws(() {print(l1.libFunc);});
Expect.throws(() {print(l1.LibClass.id);});
Expect.throws(() {print(l1.LibMixin.id);});
Expect.throws(() {print(l1.LibEnum.id);});
Expect.throws(() {print(l1.LibExt.id);});
Expect.throws(() {print(l1.LibET.id);});

await l1.loadLibrary();

Expect.equals("scope_lib1 libVar", l1.libVar);
Expect.equals("scope_lib1 libGetter", l1.libGetter);
l1.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l1.libFunc);
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l1.LibExt.id);
Expect.equals("scope_lib1 LibET", l1.LibET.id);

await l1.loadLibrary(); // Not an error
}
50 changes: 21 additions & 29 deletions LanguageFeatures/Parts-with-imports/scope_A05_t01_part2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,31 @@

part of 'scope_A05_t01_part1.dart';

import 'scope_lib2.dart' deferred as l;
import 'scope_lib2.dart' deferred as l2;

part 'scope_A05_t01_part2.dart'
part 'scope_A05_t01_part2.dart';

testPart2() async {
// From scope_lib1.dart
Expect.equals("scope_lib1 libVar", l.libVar);
Expect.equals("scope_lib1 libGetter", l.libGetter);
l.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l.libFunc);
Expect.equals("scope_lib1 LibClass", l.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l.LibExt.id);
Expect.equals("scope_lib1 LibET", l.LibET.id);
Expect.equals("scope_lib1 libVar", l1.libVar);
Expect.equals("scope_lib1 libGetter", l1.libGetter);
l1.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l1.libFunc);
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l1.LibExt.id);
Expect.equals("scope_lib1 LibET", l1.LibET.id);

// From scope_lib2.dart
Expect.throws(() {print(l.libId);});
Expect.throws(() {print(l.lib2Func());});
await l.loadLibrary();
Expect.equals("scope_lib2", l.libId);
Expect.equals("scope_lib2 lib2Func", l.lib2Func());

// Check that scope_lib1.dart members are still accessible
Expect.equals("scope_lib1 libVar", l.libVar);
Expect.equals("scope_lib1 libGetter", l.libGetter);
l.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l.libFunc);
Expect.equals("scope_lib1 LibClass", l.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l.LibExt.id);
Expect.equals("scope_lib1 LibET", l.LibET.id);

await l.loadLibrary(); // Not an error
Expect.throws(() {print(l2.libId);});
Expect.throws(() {print(l2.lib2Func());});

await l2.loadLibrary();

Expect.equals("scope_lib2", l2.libId);
Expect.equals("scope_lib2 lib2Func", l2.lib2Func());

await l1.loadLibrary(); // Not an error
await l2.loadLibrary(); // Not an error
}
25 changes: 25 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A05_t02.dart
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 Let P be a prefix scope containing all the import prefixes
/// declared by the current file. The parent scope of P is I.
/// ...
/// - If an import is `deferred`, its Pname is a deferred scope which
/// has an extra `loadLibrary` member added, as usual, and the import has an
/// implicit `hide loadLibrary` modifier.
///
/// @description Check that if an import is deferred an extra `loadLibrary`
/// member is added and it is a runtime error to access any of its members
/// before `loadLibrary()` completes successfully. Test the case when
/// `loadLibrary()` is called from another part file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

import '../../Utils/expect.dart';
part 'scope_A05_t02_part1.dart';

main() {
testPart2();
}
24 changes: 24 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A05_t02_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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 Let P be a prefix scope containing all the import prefixes
/// declared by the current file. The parent scope of P is I.
/// ...
/// - If an import is `deferred`, its Pname is a deferred scope which
/// has an extra `loadLibrary` member added, as usual, and the import has an
/// implicit `hide loadLibrary` modifier.
///
/// @description Check that if an import is deferred an extra `loadLibrary`
/// member is added and it is a runtime error to access any of its members
/// before `loadLibrary()` completes successfully. Test the case when
/// `loadLibrary()` is called from another part file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A05_t02.dart';

import 'scope_lib1.dart' deferred as l1;

part 'scope_A05_t02_part2.dart';
49 changes: 49 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A05_t02_part2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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 Let P be a prefix scope containing all the import prefixes
/// declared by the current file. The parent scope of P is I.
/// ...
/// - If an import is `deferred`, its Pname is a deferred scope which
/// has an extra `loadLibrary` member added, as usual, and the import has an
/// implicit `hide loadLibrary` modifier.
///
/// @description Check that if an import is deferred an extra `loadLibrary`
/// member is added and it is a runtime error to access any of its members
/// before `loadLibrary()` completes successfully. Test the case when
/// `loadLibrary()` is called from another part file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A05_t02_part1.dart';

part 'scope_A05_t02_part2.dart';

testPart2() async {
// From scope_lib1.dart
Expect.throws(() {print(l1.libVar);});
Expect.throws(() {print(l1.libGetter);});
Expect.throws(() {l1.libSetter = "x";});
Expect.throws(() {print(l1.libFunc);});
Expect.throws(() {print(l1.LibClass.id);});
Expect.throws(() {print(l1.LibMixin.id);});
Expect.throws(() {print(l1.LibEnum.id);});
Expect.throws(() {print(l1.LibExt.id);});
Expect.throws(() {print(l1.LibET.id);});

await l1.loadLibrary();

Expect.equals("scope_lib1 libVar", l1.libVar);
Expect.equals("scope_lib1 libGetter", l1.libGetter);
l1.libSetter = "x";
Expect.equals("scope_lib1 libFunc", l1.libFunc);
Expect.equals("scope_lib1 LibClass", l1.LibClass.id);
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id);
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id);
Expect.equals("scope_lib1 LibExt", l1.LibExt.id);
Expect.equals("scope_lib1 LibET", l1.LibET.id);

await l1.loadLibrary(); // Not an error
}

0 comments on commit 9adc17e

Please sign in to comment.