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

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

Issue 2885883002: Fix computing export scopes for library cycles and after loading. (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:front_end/src/incremental/byte_store.dart'; 10 import 'package:front_end/src/incremental/byte_store.dart';
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 _getLibraryText(library), 138 _getLibraryText(library),
139 r''' 139 r'''
140 library; 140 library;
141 import self as self; 141 import self as self;
142 import "./a.dart" as a; 142 import "./a.dart" as a;
143 143
144 static field a::A a; 144 static field a::A a;
145 '''); 145 ''');
146 } 146 }
147 147
148 test_compile_export_cycle() async {
149 writeFile('/test/.packages', 'test:lib/');
150 String aPath = '/test/lib/a.dart';
151 String bPath = '/test/lib/b.dart';
152 String cPath = '/test/lib/c.dart';
153 writeFile(aPath, 'export "b.dart"; class A {}');
154 writeFile(bPath, 'export "a.dart"; class B {}');
155 Uri cUri = writeFile(
156 cPath,
157 r'''
158 import 'b.dart';
159 A a;
160 B b;
161 ''');
162
163 {
164 Program program = await getInitialState(cUri);
165 Library library = _getLibrary(program, cUri);
166 expect(
167 _getLibraryText(library),
168 r'''
169 library;
170 import self as self;
171 import "./a.dart" as a;
172 import "./b.dart" as b;
173
174 static field a::A a;
175 static field b::B b;
176 ''');
177 }
178
179 // Update c.dart and compile.
180 // We should load the cycle [a.dart, b.dart] from the byte store.
181 // This tests that we compute export scopes after loading.
182 writeFile(
183 cPath,
184 r'''
185 import 'b.dart';
186 A a;
187 B b;
188 int c;
189 ''');
190 incrementalKernelGenerator.invalidate(cUri);
191 {
192 DeltaProgram delta = await incrementalKernelGenerator.computeDelta();
193 Program program = delta.newProgram;
194 Library library = _getLibrary(program, cUri);
195 expect(
196 _getLibraryText(library),
197 r'''
198 library;
199 import self as self;
200 import "./a.dart" as a;
201 import "./b.dart" as b;
202 import "dart:core" as core;
203
204 static field a::A a;
205 static field b::B b;
206 static field core::int c;
207 ''');
208 }
209 }
210
148 test_compile_typedef() async { 211 test_compile_typedef() async {
149 writeFile('/test/.packages', 'test:lib/'); 212 writeFile('/test/.packages', 'test:lib/');
150 String aPath = '/test/lib/a.dart'; 213 String aPath = '/test/lib/a.dart';
151 String bPath = '/test/lib/b.dart'; 214 String bPath = '/test/lib/b.dart';
152 writeFile(aPath, 'typedef int F<T>(T x);'); 215 writeFile(aPath, 'typedef int F<T>(T x);');
153 Uri bUri = writeFile( 216 Uri bUri = writeFile(
154 bPath, 217 bPath,
155 r''' 218 r'''
156 import 'a.dart'; 219 import 'a.dart';
157 F<String> f; 220 F<String> f;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 throw fail('No library found with URI "$uri"'); 424 throw fail('No library found with URI "$uri"');
362 } 425 }
363 426
364 String _getLibraryText(Library library) { 427 String _getLibraryText(Library library) {
365 StringBuffer buffer = new StringBuffer(); 428 StringBuffer buffer = new StringBuffer();
366 new Printer(buffer, syntheticNames: new NameSystem()) 429 new Printer(buffer, syntheticNames: new NameSystem())
367 .writeLibraryFile(library); 430 .writeLibraryFile(library);
368 return buffer.toString(); 431 return buffer.toString();
369 } 432 }
370 } 433 }
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