Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2498)

Unified Diff: pkg/front_end/test/incremental_kernel_generator_test.dart

Issue 2975093002: Add tests for KernelDriver. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/kernel_driver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/incremental_kernel_generator_test.dart
diff --git a/pkg/front_end/test/incremental_kernel_generator_test.dart b/pkg/front_end/test/incremental_kernel_generator_test.dart
index b504c15baeea294076f3506d803739cea2559154..d026d99c29d13300037df024983118f5bba00040 100644
--- a/pkg/front_end/test/incremental_kernel_generator_test.dart
+++ b/pkg/front_end/test/incremental_kernel_generator_test.dart
@@ -7,13 +7,10 @@ import 'dart:async';
import 'package:front_end/compiler_options.dart';
import 'package:front_end/incremental_kernel_generator.dart';
import 'package:front_end/memory_file_system.dart';
-import 'package:front_end/src/fasta/kernel/utils.dart';
import 'package:front_end/src/incremental/byte_store.dart';
import 'package:front_end/src/incremental_kernel_generator_impl.dart';
import 'package:kernel/ast.dart';
-import 'package:kernel/binary/ast_from_binary.dart';
import 'package:kernel/text/ast_to_text.dart';
-import 'package:kernel/verifier.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -134,126 +131,6 @@ static method main() → void {}
}
}
- test_compile_export() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- String cPath = '/test/lib/c.dart';
- writeFile(aPath, 'class A {}');
- writeFile(bPath, 'export "a.dart";');
- Uri cUri = writeFile(
- cPath,
- r'''
-import 'b.dart';
-A a;
-''');
-
- Program program = await getInitialState(cUri);
- Library library = _getLibrary(program, cUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "./a.dart" as a;
-
-static field a::A a;
-''');
- }
-
- test_compile_export_cycle() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- String cPath = '/test/lib/c.dart';
- writeFile(aPath, 'export "b.dart"; class A {}');
- writeFile(bPath, 'export "a.dart"; class B {}');
- Uri cUri = writeFile(
- cPath,
- r'''
-import 'b.dart';
-A a;
-B b;
-''');
-
- {
- Program program = await getInitialState(cUri);
- Library library = _getLibrary(program, cUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "./a.dart" as a;
-import "./b.dart" as b;
-
-static field a::A a;
-static field b::B b;
-''');
- }
-
- // Update c.dart and compile.
- // We should load the cycle [a.dart, b.dart] from the byte store.
- // This tests that we compute export scopes after loading.
- writeFile(
- cPath,
- r'''
-import 'b.dart';
-A a;
-B b;
-int c;
-''');
- incrementalKernelGenerator.invalidate(cUri);
- {
- DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Program program = delta.newProgram;
- Library library = _getLibrary(program, cUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "./a.dart" as a;
-import "./b.dart" as b;
-import "dart:core" as core;
-
-static field a::A a;
-static field b::B b;
-static field core::int c;
-''');
- }
- }
-
- test_compile_export_hideWithLocal() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- String cPath = '/test/lib/c.dart';
- writeFile(aPath, 'class A {} class B {}');
- writeFile(bPath, 'export "a.dart"; class B {}');
- Uri cUri = writeFile(
- cPath,
- r'''
-import 'b.dart';
-A a;
-B b;
-''');
-
- Program program = await getInitialState(cUri);
- Library library = _getLibrary(program, cUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "./a.dart" as a;
-import "./b.dart" as b;
-
-static field a::A a;
-static field b::B b;
-''');
- }
-
test_compile_includePathToMain() async {
writeFile('/test/.packages', 'test:lib/');
String aPath = '/test/lib/a.dart';
@@ -309,90 +186,6 @@ b() {
}
}
- test_compile_recompileMixin() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- String cPath = '/test/lib/c.dart';
-
- Uri aUri = writeFile(
- aPath,
- r'''
-import 'b.dart';
-main() {
- new B().foo();
-}
-''');
- Uri bUri = writeFile(
- bPath,
- r'''
-import 'c.dart';
-class B extends Object with C {}
-''');
- Uri cUri = writeFile(
- cPath,
- r'''
-class C {
- void foo() {
- print(0);
- }
-}
-''');
-
- {
- Program program = await getInitialState(aUri);
- _assertLibraryUris(program,
- includes: [aUri, bUri, cUri, Uri.parse('dart:core')]);
- }
-
- // Update c.dart and compute the delta.
- // Includes: c.dart, b.dart and a.dart files.
- // Compiled: c.dart (changed) and b.dart (has mixin), but not a.dart file.
- writeFile(
- cPath,
- r'''
-class C {
- void foo() {
- print(1);
- }
-}
-''');
- incrementalKernelGenerator.invalidate(cUri);
- {
- DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Program program = delta.newProgram;
- _assertLibraryUris(program,
- includes: [aUri, bUri, cUri], excludes: [Uri.parse('dart:core')]);
- // Compiled: c.dart (changed), and b.dart (has mixin).
- _assertCompiledUris([cUri, bUri]);
- }
- }
-
- test_compile_typedef() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- writeFile(aPath, 'typedef int F<T>(T x);');
- Uri bUri = writeFile(
- bPath,
- r'''
-import 'a.dart';
-F<String> f;
-''');
-
- Program program = await getInitialState(bUri);
- Library library = _getLibrary(program, bUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "dart:core" as core;
-
-static field (core::String) → core::int f;
-''');
- }
-
test_invalidateAll() async {
writeFile('/test/.packages', '');
Uri aUri = writeFile('/test/a.dart', "import 'b.dart';\nint a = b;");
@@ -413,129 +206,6 @@ static field (core::String) → core::int f;
expect(_getLibraryText(_getLibrary(program, bUri)), contains("b = 2"));
}
- test_limited_ast_to_binary() async {
- writeFile('/test/.packages', 'test:lib/');
- String aPath = '/test/lib/a.dart';
- String bPath = '/test/lib/b.dart';
- writeFile(
- aPath,
- r'''
-int topField = 0;
-int get topGetter => 0;
-int topFunction({p}) => 0;
-
-abstract class I {
- int interfaceField;
- int get interfaceGetter;
- int interfaceMethod();
-}
-
-class A implements I {
- static int staticField;
- static int get staticGetter => 0;
- static int staticMethod() => 0;
-
- int instanceField;
- int get instanceGetter => 0;
- int instanceMethod() => 0;
-
- int interfaceField;
- int get interfaceGetter => 0;
- int interfaceMethod() => 0;
-
- A();
- A.named();
-}
-''');
- Uri bUri = writeFile(
- bPath,
- r'''
-import 'a.dart';
-
-class B extends A {
- B() : super();
- B.named() : super.named();
-
- void foo() {
- super.instanceMethod();
- instanceMethod();
-
- super.interfaceField;
- super.interfaceField = 0;
- super.interfaceGetter;
- super.interfaceMethod();
- }
-
- int instanceMethod() => 0;
-
- int interfaceField;
- int get interfaceGetter => 0;
- int interfaceMethod() => 0;
-}
-
-main() {
- topField;
- topField = 0;
- var v1 = topGetter;
- var v2 = topFunction(p: 0);
-
- A.staticField;
- A.staticField = 0;
- var v3 = A.staticGetter;
- var v4 = A.staticMethod();
-
- var a = new A();
-
- a.instanceField;
- a.instanceField = 0;
- var v5 = a.instanceGetter;
- var v6 = a.instanceMethod();
-
- a.interfaceField;
- a.interfaceField = 0;
- var v7 = a.interfaceGetter;
- var v8 = a.interfaceMethod();
-}
-''');
-
- Program program = await getInitialState(bUri);
-
- String initialKernelText;
- List<int> bytes;
- {
- Library initialLibrary = _getLibrary(program, bUri);
- initialKernelText = _getLibraryText(initialLibrary);
-
- bytes = serializeProgram(program,
- filter: (library) => library.importUri == bUri);
-
- // Remove b.dart from the program.
- // So, the program is now ready for re-adding the library.
- program.mainMethod = null;
- program.libraries.remove(initialLibrary);
- program.root.removeChild(initialLibrary.importUri.toString());
- }
-
- // Load b.dart from bytes using the initial name root, so that
- // serialized canonical names can be linked to corresponding nodes.
- Library loadedLibrary;
- {
- var programForLoading = new Program(nameRoot: program.root);
- var reader = new BinaryBuilder(bytes);
- reader.readProgram(programForLoading);
- loadedLibrary = _getLibrary(programForLoading, bUri);
- }
-
- // Add the library into the program.
- program.libraries.add(loadedLibrary);
- loadedLibrary.parent = program;
- program.mainMethod = loadedLibrary.procedures
- .firstWhere((procedure) => procedure.name.name == 'main');
-
- expect(_getLibraryText(loadedLibrary), initialKernelText);
- verifyProgram(program);
- }
-
test_updateEntryPoint() async {
writeFile('/test/.packages', 'test:lib/');
String path = '/test/lib/test.dart';
@@ -600,150 +270,6 @@ static method main() → dynamic {
}
}
- test_updatePackageSourceUsingFileUri() async {
- writeFile('/test/.packages', 'test:lib/');
- Uri aFileUri = writeFile(
- '/test/bin/a.dart',
- r'''
-import 'package:test/b.dart';
-var a = b;
-''');
- Uri bFileUri = writeFile('/test/lib/b.dart', 'var b = 1;');
- Uri bPackageUri = Uri.parse('package:test/b.dart');
-
- // Compute the initial state.
- {
- Program program = await getInitialState(aFileUri);
- Library library = _getLibrary(program, aFileUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "dart:core" as core;
-import "package:test/b.dart" as b;
-
-static field core::int a = b::b;
-''');
- }
-
- // Update b.dart and use file URI to invalidate it.
- // The delta is recomputed even though b.dart is used with the package URI.
- writeFile('/test/lib/b.dart', 'var b = 1.2;');
- incrementalKernelGenerator.invalidate(bFileUri);
- {
- DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Program program = delta.newProgram;
- _assertLibraryUris(program, includes: [aFileUri, bPackageUri]);
- Library library = _getLibrary(program, aFileUri);
- expect(
- _getLibraryText(library),
- r'''
-library;
-import self as self;
-import "dart:core" as core;
-import "package:test/b.dart" as b;
-
-static field core::double a = b::b;
-''');
- }
- }
-
- test_updatePart() async {
- writeFile('/test/.packages', 'test:lib/');
- String libPath = '/test/lib/test.dart';
- String partPath = '/test/lib/bar.dart';
- Uri libUri = writeFile(
- libPath,
- r'''
-library foo;
-part 'bar.dart';
-var a = 1;
-var c = b;
-void main() {}
-''');
- Uri partUri = writeFile(
- partPath,
- r'''
-part of foo;
-var b = 2;
-var d = a;
-''');
-
- // Check the initial state - types flow between the part and the library.
- Program program = await getInitialState(libUri);
- Library library = _getLibrary(program, libUri);
- expect(
- _getLibraryText(library),
- r'''
-library foo;
-import self as self;
-import "dart:core" as core;
-
-static field core::int a = 1;
-static field core::int c = self::b;
-static field core::int b = 2 /* from file:///test/lib/bar.dart */;
-static field core::int d = self::a /* from file:///test/lib/bar.dart */;
-static method main() → void {}
-''');
-
- // Update [b] in the part, the type is changed in the part and library.
- {
- writeFile(
- partPath,
- r'''
-part of foo;
-var b = 2.3;
-var d = a;
-''');
- incrementalKernelGenerator.invalidate(partUri);
- DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Library library = _getLibrary(delta.newProgram, libUri);
- expect(
- _getLibraryText(library),
- r'''
-library foo;
-import self as self;
-import "dart:core" as core;
-
-static field core::int a = 1;
-static field core::double c = self::b;
-static field core::double b = 2.3 /* from file:///test/lib/bar.dart */;
-static field core::int d = self::a /* from file:///test/lib/bar.dart */;
-static method main() → void {}
-''');
- }
-
- // Update [a] in the library, the type is changed in the part and library.
- {
- writeFile(
- libPath,
- r'''
-library foo;
-part 'bar.dart';
-var a = 'aaa';
-var c = b;
-void main() {}
-''');
- incrementalKernelGenerator.invalidate(libUri);
- DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
- Library library = _getLibrary(delta.newProgram, libUri);
- expect(
- _getLibraryText(library),
- r'''
-library foo;
-import self as self;
-import "dart:core" as core;
-
-static field core::String a = "aaa";
-static field core::double c = self::b;
-static field core::double b = 2.3 /* from file:///test/lib/bar.dart */;
-static field core::String d = self::a /* from file:///test/lib/bar.dart */;
-static method main() → void {}
-''');
- }
- }
-
test_watch() async {
writeFile('/test/.packages', 'test:lib/');
String aPath = '/test/lib/a.dart';
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/kernel_driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698