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

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

Issue 2638423002: Fix incremental kernel builder to handle multiple calls to computeDelta. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/front_end/test/incremental_kernel_generator_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/incremental_resolved_ast_generator_test.dart
diff --git a/pkg/front_end/test/incremental_resolved_ast_generator_test.dart b/pkg/front_end/test/incremental_resolved_ast_generator_test.dart
index be4bd57db57b405dba39b1fa70f10da1cb8aff29..1f137e39ccd936cf372c74842f1d4cb9ff9960d6 100644
--- a/pkg/front_end/test/incremental_resolved_ast_generator_test.dart
+++ b/pkg/front_end/test/incremental_resolved_ast_generator_test.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
import 'package:front_end/compiler_options.dart';
@@ -54,18 +55,61 @@ class IncrementalResolvedAstGeneratorTest {
return (await incrementalResolvedAstGenerator.computeDelta()).newState;
}
- test_emptyProgram() async {
- writeFiles({'/foo.dart': 'main() {}'});
+ test_incrementalUpdate_referenceToCore() async {
+ // TODO(paulberry): test parts.
+ writeFiles({'/foo.dart': 'main() { print(1); }'});
var fooUri = Uri.parse('file:///foo.dart');
var initialProgram = await getInitialProgram(fooUri);
expect(initialProgram.keys, unorderedEquals([fooUri]));
- var unit = initialProgram[fooUri].definingCompilationUnit;
- expect(unit.declarations, hasLength(1));
- expect(unit.declarations[0], new isInstanceOf<FunctionDeclaration>());
- var main = unit.declarations[0] as FunctionDeclaration;
- expect(main.name.name, 'main');
- // TODO(paulberry): test that stuff is actually resolved.
- // TODO(paulberry): test parts.
+ void _checkMain(CompilationUnit unit, int expectedArgument) {
danrubel 2017/01/18 20:47:36 nit: blank line before inner method helps readabil
Paul Berry 2017/01/18 22:36:31 Done.
+ expect(unit.declarations, hasLength(1));
+ expect(unit.declarations[0], new isInstanceOf<FunctionDeclaration>());
+ var main = unit.declarations[0] as FunctionDeclaration;
+ expect(main.name.name, 'main');
+ expect(
+ main.functionExpression.body, new isInstanceOf<BlockFunctionBody>());
+ var blockFunctionBody = main.functionExpression.body as BlockFunctionBody;
+ expect(blockFunctionBody.block.statements, hasLength(1));
+ expect(blockFunctionBody.block.statements[0],
+ new isInstanceOf<ExpressionStatement>());
+ var expressionStatement =
+ blockFunctionBody.block.statements[0] as ExpressionStatement;
+ expect(
+ expressionStatement.expression, new isInstanceOf<MethodInvocation>());
+ var methodInvocation = expressionStatement.expression as MethodInvocation;
+ expect(methodInvocation.methodName.name, 'print');
+ var printElement =
+ resolutionMap.staticElementForIdentifier(methodInvocation.methodName);
+ expect(printElement, isNotNull);
+ expect(printElement.library.source.uri, Uri.parse('dart:core'));
+ expect(methodInvocation.argumentList.arguments, hasLength(1));
+ expect(methodInvocation.argumentList.arguments[0],
+ new isInstanceOf<IntegerLiteral>());
+ var integerLiteral =
+ methodInvocation.argumentList.arguments[0] as IntegerLiteral;
+ expect(integerLiteral.value, expectedArgument);
+ }
+
+ _checkMain(initialProgram[fooUri].definingCompilationUnit, 1);
+ writeFiles({'/foo.dart': 'main() { print(2); }'});
+ // TODO(paulberry): verify that the file isn't actually reread until
+ // invalidate is called.
+ // var deltaProgram1 = await incrementalResolvedAstGenerator.computeDelta();
+ // expect(deltaProgram1.newState, isEmpty);
+ incrementalResolvedAstGenerator.invalidateAll();
+ var deltaProgram2 = await incrementalResolvedAstGenerator.computeDelta();
+ expect(deltaProgram2.newState.keys, unorderedEquals([fooUri]));
+ _checkMain(deltaProgram2.newState[fooUri].definingCompilationUnit, 2);
+ }
+
+ test_invalidateAllBeforeInitialProgram() async {
+ incrementalResolvedAstGenerator = new IncrementalResolvedAstGenerator(
+ Uri.parse('file:///foo.dart'),
+ new CompilerOptions()
+ ..fileSystem = fileSystem
+ ..chaseDependencies = true
+ ..packagesFileUri = new Uri());
+ incrementalResolvedAstGenerator.invalidateAll();
}
/// Write the given file contents to the virtual filesystem.
« no previous file with comments | « pkg/front_end/test/incremental_kernel_generator_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698