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

Side by Side Diff: pkg/front_end/test/incremental_resolved_ast_generator_test.dart

Issue 2644953002: Store a file state in the incremental resolved AST generator. (Closed)
Patch Set: Additional testing logic 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/file_system/physical_file_system.dart'; 10 import 'package:analyzer/file_system/physical_file_system.dart';
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 expect(initialProgram.keys, unorderedEquals([fooUri])); 63 expect(initialProgram.keys, unorderedEquals([fooUri]));
64 64
65 void _checkMain(CompilationUnit unit, int expectedArgument) { 65 void _checkMain(CompilationUnit unit, int expectedArgument) {
66 var mainStatements = _getFunctionStatements(_getFunction(unit, 'main')); 66 var mainStatements = _getFunctionStatements(_getFunction(unit, 'main'));
67 expect(mainStatements, hasLength(1)); 67 expect(mainStatements, hasLength(1));
68 _checkPrintLiteralInt(mainStatements[0], expectedArgument); 68 _checkPrintLiteralInt(mainStatements[0], expectedArgument);
69 } 69 }
70 70
71 _checkMain(initialProgram[fooUri].definingCompilationUnit, 1); 71 _checkMain(initialProgram[fooUri].definingCompilationUnit, 1);
72 writeFiles({'/foo.dart': 'main() { print(2); }'}); 72 writeFiles({'/foo.dart': 'main() { print(2); }'});
73 // TODO(paulberry): verify that the file isn't actually reread until 73 // Verify that the file isn't actually reread until invalidate is called.
74 // invalidate is called. 74 var deltaProgram1 = await incrementalResolvedAstGenerator.computeDelta();
75 // var deltaProgram1 = await incrementalResolvedAstGenerator.computeDelta(); 75 // TODO(paulberry): since there is no delta, computeDelta should return an
76 // empty map.
76 // expect(deltaProgram1.newState, isEmpty); 77 // expect(deltaProgram1.newState, isEmpty);
78 expect(deltaProgram1.newState.keys, unorderedEquals([fooUri]));
79 _checkMain(deltaProgram1.newState[fooUri].definingCompilationUnit, 1);
77 incrementalResolvedAstGenerator.invalidateAll(); 80 incrementalResolvedAstGenerator.invalidateAll();
78 var deltaProgram2 = await incrementalResolvedAstGenerator.computeDelta(); 81 var deltaProgram2 = await incrementalResolvedAstGenerator.computeDelta();
79 expect(deltaProgram2.newState.keys, unorderedEquals([fooUri])); 82 expect(deltaProgram2.newState.keys, unorderedEquals([fooUri]));
80 _checkMain(deltaProgram2.newState[fooUri].definingCompilationUnit, 2); 83 _checkMain(deltaProgram2.newState[fooUri].definingCompilationUnit, 2);
81 } 84 }
82 85
83 test_invalidateAllBeforeInitialProgram() async { 86 test_invalidateAllBeforeInitialProgram() async {
84 incrementalResolvedAstGenerator = new IncrementalResolvedAstGenerator( 87 incrementalResolvedAstGenerator = new IncrementalResolvedAstGenerator(
85 Uri.parse('file:///foo.dart'), 88 Uri.parse('file:///foo.dart'),
86 new CompilerOptions() 89 new CompilerOptions()
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 164 }
162 throw fail('No function declaration found with name "$name"'); 165 throw fail('No function declaration found with name "$name"');
163 } 166 }
164 167
165 NodeList<Statement> _getFunctionStatements(FunctionDeclaration function) { 168 NodeList<Statement> _getFunctionStatements(FunctionDeclaration function) {
166 var body = function.functionExpression.body; 169 var body = function.functionExpression.body;
167 expect(body, new isInstanceOf<BlockFunctionBody>()); 170 expect(body, new isInstanceOf<BlockFunctionBody>());
168 return (body as BlockFunctionBody).block.statements; 171 return (body as BlockFunctionBody).block.statements;
169 } 172 }
170 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698