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

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

Issue 2871783002: Start using FileState/FileSystemState to provide consistent view. (Closed)
Patch Set: 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 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:front_end/compiler_options.dart'; 7 import 'package:front_end/compiler_options.dart';
8 import 'package:front_end/incremental_kernel_generator.dart'; 8 import 'package:front_end/incremental_kernel_generator.dart';
9 import 'package:front_end/memory_file_system.dart'; 9 import 'package:front_end/memory_file_system.dart';
10 import 'package:kernel/ast.dart'; 10 import 'package:kernel/ast.dart';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 writeFile('/test/.packages', 'test:lib/'); 50 writeFile('/test/.packages', 'test:lib/');
51 String path = '/test/lib/test.dart'; 51 String path = '/test/lib/test.dart';
52 Uri uri = writeFile( 52 Uri uri = writeFile(
53 path, 53 path,
54 r''' 54 r'''
55 main() { 55 main() {
56 var v = 1; 56 var v = 1;
57 } 57 }
58 '''); 58 ''');
59 59
60 // Compute the initial state 60 String initialText = r'''
61 {
62 Program program = await getInitialState(uri);
63 Library library = _getLibrary(program, uri);
64 expect(
65 _getLibraryText(library),
66 r'''
67 library; 61 library;
68 import self as self; 62 import self as self;
69 import "dart:core" as core; 63 import "dart:core" as core;
70 64
71 static method main() → dynamic { 65 static method main() → dynamic {
72 core::int v = 1; 66 core::int v = 1;
73 } 67 }
74 '''); 68 ''';
69
70 // Compute the initial state.
71 {
72 Program program = await getInitialState(uri);
73 Library library = _getLibrary(program, uri);
74 expect(_getLibraryText(library), initialText);
75 } 75 }
76 76
77 // Update the entry point library. 77 // Update the entry point library.
78 writeFile( 78 writeFile(
79 path, 79 path,
80 r''' 80 r'''
81 main() { 81 main() {
82 var v = 2.3; 82 var v = 2.3;
83 } 83 }
84 '''); 84 ''');
85 85
86 // The delta has the updated entry point library. 86 // Because we have not invalidated the file, we get the same library.
87 // TODO(scheglov) Eventually we should get an empty Program.
87 { 88 {
88 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); 89 DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
89 Program program = delta.newProgram; 90 Library library = _getLibrary(delta.newProgram, uri);
90 Library library = _getLibrary(program, uri); 91 expect(_getLibraryText(library), initialText);
92 }
93
94 // Invalidate the file, so get the new text.
95 incrementalKernelGenerator.invalidate(uri);
96 {
97 DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
98 Library library = _getLibrary(delta.newProgram, uri);
91 expect( 99 expect(
92 _getLibraryText(library), 100 _getLibraryText(library),
93 r''' 101 r'''
94 library; 102 library;
95 import self as self; 103 import self as self;
96 import "dart:core" as core; 104 import "dart:core" as core;
97 105
98 static method main() → dynamic { 106 static method main() → dynamic {
99 core::double v = 2.3; 107 core::double v = 2.3;
100 } 108 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 throw fail('No library found with URI "$uri"'); 151 throw fail('No library found with URI "$uri"');
144 } 152 }
145 153
146 String _getLibraryText(Library library) { 154 String _getLibraryText(Library library) {
147 StringBuffer buffer = new StringBuffer(); 155 StringBuffer buffer = new StringBuffer();
148 new Printer(buffer, syntheticNames: new NameSystem()) 156 new Printer(buffer, syntheticNames: new NameSystem())
149 .writeLibraryFile(library); 157 .writeLibraryFile(library);
150 return buffer.toString(); 158 return buffer.toString();
151 } 159 }
152 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698