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

Side by Side Diff: pkg/front_end/test/src/incremental/file_state_test.dart

Issue 2877193003: Start actually adding incrementality into incremental kernel generator. (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 'package:front_end/memory_file_system.dart'; 5 import 'package:front_end/memory_file_system.dart';
6 import 'package:front_end/src/fasta/translate_uri.dart'; 6 import 'package:front_end/src/fasta/translate_uri.dart';
7 import 'package:front_end/src/incremental/file_state.dart'; 7 import 'package:front_end/src/incremental/file_state.dart';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 10
11 import 'mock_sdk.dart'; 11 import 'mock_sdk.dart';
12 12
13 main() { 13 main() {
14 defineReflectiveSuite(() { 14 defineReflectiveSuite(() {
15 defineReflectiveTests(FileSystemStateTest); 15 defineReflectiveTests(FileSystemStateTest);
16 }); 16 });
17 } 17 }
18 18
19 @reflectiveTest 19 @reflectiveTest
20 class FileSystemStateTest { 20 class FileSystemStateTest {
21 final fileSystem = new MemoryFileSystem(Uri.parse('file:///')); 21 final fileSystem = new MemoryFileSystem(Uri.parse('file:///'));
22 final TranslateUri uriTranslator = new TranslateUri({}, {}); 22 final TranslateUri uriTranslator = new TranslateUri({}, {});
23 FileSystemState fsState; 23 FileSystemState fsState;
24 24
25 Uri _coreUri; 25 Uri _coreUri;
26 26
27 void setUp() { 27 void setUp() {
28 Map<String, Uri> dartLibraries = createSdkFiles(fileSystem); 28 Map<String, Uri> dartLibraries = createSdkFiles(fileSystem);
29 uriTranslator.dartLibraries.addAll(dartLibraries); 29 uriTranslator.dartLibraries.addAll(dartLibraries);
30 _coreUri = uriTranslator.dartLibraries['core']; 30 _coreUri = Uri.parse('dart:core');
31 expect(_coreUri, isNotNull); 31 expect(_coreUri, isNotNull);
32 fsState = new FileSystemState(fileSystem, uriTranslator); 32 fsState = new FileSystemState(fileSystem, uriTranslator);
33 } 33 }
34 34
35 test_getFile() async { 35 test_getFile() async {
36 var a = writeFile('/a.dart', ''); 36 var a = writeFile('/a.dart', '');
37 var b = writeFile('/b.dart', ''); 37 var b = writeFile('/b.dart', '');
38 var c = writeFile('/c.dart', ''); 38 var c = writeFile('/c.dart', '');
39 var d = writeFile( 39 var d = writeFile(
40 '/d.dart', 40 '/d.dart',
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 /// Write the given [text] of the file with the given [path] into the 129 /// Write the given [text] of the file with the given [path] into the
130 /// virtual filesystem. Return the URI of the file. 130 /// virtual filesystem. Return the URI of the file.
131 Uri writeFile(String path, String text) { 131 Uri writeFile(String path, String text) {
132 Uri uri = Uri.parse('file://$path'); 132 Uri uri = Uri.parse('file://$path');
133 fileSystem.entityForUri(uri).writeAsStringSync(text); 133 fileSystem.entityForUri(uri).writeAsStringSync(text);
134 return uri; 134 return uri;
135 } 135 }
136 136
137 void _assertImportedUris(FileState file, List<Uri> expectedUris) { 137 void _assertImportedUris(FileState file, List<Uri> expectedUris) {
138 Iterable<Uri> importedUris = _toFileUris(file.importedLibraries); 138 Iterable<Uri> importedUris = _toUris(file.importedLibraries);
139 expect(importedUris, unorderedEquals(expectedUris)); 139 expect(importedUris, unorderedEquals(expectedUris));
140 } 140 }
141 141
142 Iterable<Uri> _toFileUris(List<FileState> files) { 142 Iterable<Uri> _toUris(List<FileState> files) {
143 return files.map((f) => f.fileUri); 143 return files.map((f) => f.uri);
144 } 144 }
145 145
146 Uri _writeFileDirectives(String path, 146 Uri _writeFileDirectives(String path,
147 {List<String> imports: const [], List<String> exports: const []}) { 147 {List<String> imports: const [], List<String> exports: const []}) {
148 return writeFile( 148 return writeFile(
149 path, 149 path,
150 ''' 150 '''
151 ${imports.map((uri) => 'import "$uri";').join('\n')} 151 ${imports.map((uri) => 'import "$uri";').join('\n')}
152 ${exports.map((uri) => 'export "$uri";').join('\n')} 152 ${exports.map((uri) => 'export "$uri";').join('\n')}
153 '''); 153 ''');
154 } 154 }
155 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698