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

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

Issue 2896493002: Add LimitedBinaryPrinter, tests and switch incremental generator to it. (Closed)
Patch Set: Move LimitedBinaryPrinter to kernel, remove comments. Created 3 years, 7 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
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 4f5cafee809cd60139258d5a69a1aa9b3b24d0dc..6ee3a21e47b3e6b2f341571c5be27e34f9c238d3 100644
--- a/pkg/front_end/test/incremental_kernel_generator_test.dart
+++ b/pkg/front_end/test/incremental_kernel_generator_test.dart
@@ -8,8 +8,12 @@ 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/incremental/byte_store.dart';
+import '../../kernel/lib/binary/limited_ast_to_binary.dart';
ahe 2017/05/24 08:36:00 You probably want to use a package URI here.
scheglov 2017/05/25 17:44:09 Fixed. Thanks.
+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';
@@ -316,6 +320,104 @@ static field (core::String) → core::int f;
''');
}
+ 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;
+
+class A {
+ static int staticField;
+ static int get staticGetter => 0;
+ static int staticMethod() => 0;
+
+ int instanceField;
+ int get instanceGetter => 0;
+ int instanceMethod() => 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();
+ }
+
+ int instanceMethod() => 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();
+}
+''');
+
+ Program program = await getInitialState(bUri);
+
+ String initialKernelText;
+ List<int> bytes;
+ {
+ Library initialLibrary = _getLibrary(program, bUri);
+ initialKernelText = _getLibraryText(initialLibrary);
+
+ var byteSink = new ByteSink();
+ var printer = new LimitedBinaryPrinter(
+ byteSink, (library) => library.importUri == bUri);
+ printer.writeProgramFile(program);
+ bytes = byteSink.builder.takeBytes();
+
+ // Remove b.dart from the program.
+ // So, the program is now ready for re-adding the library.
+ 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;
+
+ expect(_getLibraryText(loadedLibrary), initialKernelText);
+ verifyProgram(program);
+ }
+
test_updateEntryPoint() async {
writeFile('/test/.packages', 'test:lib/');
String path = '/test/lib/test.dart';
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.dart ('k') | pkg/kernel/lib/binary/ast_to_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698