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

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

Issue 2864243004: Revert "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
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 String initialText = r''' 60 // Compute the initial state
61 {
62 Program program = await getInitialState(uri);
63 Library library = _getLibrary(program, uri);
64 expect(
65 _getLibraryText(library),
66 r'''
61 library; 67 library;
62 import self as self; 68 import self as self;
63 import "dart:core" as core; 69 import "dart:core" as core;
64 70
65 static method main() → dynamic { 71 static method main() → dynamic {
66 core::int v = 1; 72 core::int v = 1;
67 } 73 }
68 '''; 74 ''');
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 // Because we have not invalidated the file, we get the same library. 86 // The delta has the updated entry point library.
87 // TODO(scheglov) Eventually we should get an empty Program.
88 { 87 {
89 DeltaProgram delta = await incrementalKernelGenerator.computeDelta(); 88 DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
90 Library library = _getLibrary(delta.newProgram, uri); 89 Program program = delta.newProgram;
91 expect(_getLibraryText(library), initialText); 90 Library library = _getLibrary(program, uri);
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);
99 expect( 91 expect(
100 _getLibraryText(library), 92 _getLibraryText(library),
101 r''' 93 r'''
102 library; 94 library;
103 import self as self; 95 import self as self;
104 import "dart:core" as core; 96 import "dart:core" as core;
105 97
106 static method main() → dynamic { 98 static method main() → dynamic {
107 core::double v = 2.3; 99 core::double v = 2.3;
108 } 100 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 throw fail('No library found with URI "$uri"'); 143 throw fail('No library found with URI "$uri"');
152 } 144 }
153 145
154 String _getLibraryText(Library library) { 146 String _getLibraryText(Library library) {
155 StringBuffer buffer = new StringBuffer(); 147 StringBuffer buffer = new StringBuffer();
156 new Printer(buffer, syntheticNames: new NameSystem()) 148 new Printer(buffer, syntheticNames: new NameSystem())
157 .writeLibraryFile(library); 149 .writeLibraryFile(library);
158 return buffer.toString(); 150 return buffer.toString();
159 } 151 }
160 } 152 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/incremental_kernel_generator_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698