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

Side by Side Diff: pkg/front_end/test/src/base/processed_options_test.dart

Issue 2869563002: Initial version of Fasta based IncrementalKernelGenerator. (Closed)
Patch Set: Add mock SDK. 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:analyzer/src/summary/format.dart'; 7 import 'package:analyzer/src/summary/format.dart';
8 import 'package:front_end/compiler_options.dart'; 8 import 'package:front_end/compiler_options.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/base/processed_options.dart'; 10 import 'package:front_end/src/base/processed_options.dart';
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 test_getSdkSummary_summaryLocationProvided() async { 76 test_getSdkSummary_summaryLocationProvided() async {
77 var uri = Uri.parse('file:///sdkSummary'); 77 var uri = Uri.parse('file:///sdkSummary');
78 writeMockSummaryTo(uri); 78 writeMockSummaryTo(uri);
79 checkMockSummary(new CompilerOptions() 79 checkMockSummary(new CompilerOptions()
80 ..fileSystem = fileSystem 80 ..fileSystem = fileSystem
81 ..sdkSummary = uri); 81 ..sdkSummary = uri);
82 } 82 }
83 83
84 test_getUriResolver_explicitPackagesFile() async { 84 test_getUriTranslator_explicitPackagesFile() async {
85 // This .packages file should be ignored. 85 // This .packages file should be ignored.
86 fileSystem 86 fileSystem
87 .entityForUri(Uri.parse('file:///.packages')) 87 .entityForUri(Uri.parse('file:///.packages'))
88 .writeAsStringSync('foo:bar\n'); 88 .writeAsStringSync('foo:bar\n');
89 // This one should be used. 89 // This one should be used.
90 fileSystem 90 fileSystem
91 .entityForUri(Uri.parse('file:///explicit.packages')) 91 .entityForUri(Uri.parse('file:///explicit.packages'))
92 .writeAsStringSync('foo:baz\n'); 92 .writeAsStringSync('foo:baz\n');
93 var raw = new CompilerOptions() 93 var raw = new CompilerOptions()
94 ..fileSystem = fileSystem 94 ..fileSystem = fileSystem
95 ..packagesFileUri = Uri.parse('file:///explicit.packages'); 95 ..packagesFileUri = Uri.parse('file:///explicit.packages');
96 var processed = new ProcessedOptions(raw); 96 var processed = new ProcessedOptions(raw);
97 var uriResolver = await processed.getUriResolver(); 97 var uriTranslator = await processed.getUriTranslator();
98 expect(uriResolver.packages, {'foo': Uri.parse('file:///baz/')}); 98 expect(uriTranslator.packages, {'foo': Uri.parse('file:///baz/')});
99 } 99 }
100 100
101 test_getUriResolver_explicitPackagesFile_withBaseLocation() async { 101 test_getUriTranslator_explicitPackagesFile_withBaseLocation() async {
102 // This .packages file should be ignored. 102 // This .packages file should be ignored.
103 fileSystem 103 fileSystem
104 .entityForUri(Uri.parse('file:///.packages')) 104 .entityForUri(Uri.parse('file:///.packages'))
105 .writeAsStringSync('foo:bar\n'); 105 .writeAsStringSync('foo:bar\n');
106 // This one should be used. 106 // This one should be used.
107 fileSystem 107 fileSystem
108 .entityForUri(Uri.parse('file:///base/location/explicit.packages')) 108 .entityForUri(Uri.parse('file:///base/location/explicit.packages'))
109 .writeAsStringSync('foo:baz\n'); 109 .writeAsStringSync('foo:baz\n');
110 var raw = new CompilerOptions() 110 var raw = new CompilerOptions()
111 ..fileSystem = fileSystem 111 ..fileSystem = fileSystem
112 ..packagesFileUri = Uri.parse('file:///base/location/explicit.packages'); 112 ..packagesFileUri = Uri.parse('file:///base/location/explicit.packages');
113 var processed = new ProcessedOptions(raw); 113 var processed = new ProcessedOptions(raw);
114 var uriResolver = await processed.getUriResolver(); 114 var uriTranslator = await processed.getUriTranslator();
115 expect( 115 expect(uriTranslator.packages,
116 uriResolver.packages, {'foo': Uri.parse('file:///base/location/baz/')}); 116 {'foo': Uri.parse('file:///base/location/baz/')});
117 } 117 }
118 118
119 test_getUriResolver_noPackages() async { 119 test_getUriTranslator_noPackages() async {
120 // .packages file should be ignored. 120 // .packages file should be ignored.
121 fileSystem 121 fileSystem
122 .entityForUri(Uri.parse('file:///.packages')) 122 .entityForUri(Uri.parse('file:///.packages'))
123 .writeAsStringSync('foo:bar\n'); 123 .writeAsStringSync('foo:bar\n');
124 var raw = new CompilerOptions() 124 var raw = new CompilerOptions()
125 ..fileSystem = fileSystem 125 ..fileSystem = fileSystem
126 ..packagesFileUri = new Uri(); 126 ..packagesFileUri = new Uri();
127 var processed = new ProcessedOptions(raw); 127 var processed = new ProcessedOptions(raw);
128 var uriResolver = await processed.getUriResolver(); 128 var uriTranslator = await processed.getUriTranslator();
129 expect(uriResolver.packages, isEmpty); 129 expect(uriTranslator.packages, isEmpty);
130 } 130 }
131 131
132 void writeMockSummaryTo(Uri uri) { 132 void writeMockSummaryTo(Uri uri) {
133 fileSystem.entityForUri(uri).writeAsBytesSync(mockSdkSummary.toBuffer()); 133 fileSystem.entityForUri(uri).writeAsBytesSync(mockSdkSummary.toBuffer());
134 } 134 }
135 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698