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

Side by Side Diff: pkg/analyzer/test/src/task/strong/strong_test_helper.dart

Issue 2986063002: Avoid issuing incorrect errors when super mixins are enabled (Closed)
Patch Set: Address comments Created 3 years, 4 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/analyzer/test/src/task/strong/inferred_type_test.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 library analyzer.test.src.task.strong.strong_test_helper; 7 library analyzer.test.src.task.strong.strong_test_helper;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 /// errors/warnings/hints match the expected value. 266 /// errors/warnings/hints match the expected value.
267 /// 267 ///
268 /// See [addFile] for more information about how to encode expectations in 268 /// See [addFile] for more information about how to encode expectations in
269 /// the file text. 269 /// the file text.
270 /// 270 ///
271 /// Returns the main resolved library. This can be used for further checks. 271 /// Returns the main resolved library. This can be used for further checks.
272 Future<CompilationUnit> check( 272 Future<CompilationUnit> check(
273 {bool declarationCasts: true, 273 {bool declarationCasts: true,
274 bool implicitCasts: true, 274 bool implicitCasts: true,
275 bool implicitDynamic: true, 275 bool implicitDynamic: true,
276 List<String> nonnullableTypes: 276 List<String> nonnullableTypes: AnalysisOptionsImpl.NONNULLABLE_TYPES,
277 AnalysisOptionsImpl.NONNULLABLE_TYPES}) async { 277 bool superMixins: false}) async {
278 _checkCalled = true; 278 _checkCalled = true;
279 279
280 File mainFile = 280 File mainFile =
281 _resourceProvider.getFile(_resourceProvider.convertPath('/main.dart')); 281 _resourceProvider.getFile(_resourceProvider.convertPath('/main.dart'));
282 expect(mainFile.exists, true, reason: '`/main.dart` is missing'); 282 expect(mainFile.exists, true, reason: '`/main.dart` is missing');
283 283
284 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); 284 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl();
285 analysisOptions.strongMode = true; 285 analysisOptions.strongMode = true;
286 analysisOptions.strongModeHints = true; 286 analysisOptions.strongModeHints = true;
287 analysisOptions.declarationCasts = declarationCasts; 287 analysisOptions.declarationCasts = declarationCasts;
288 analysisOptions.implicitCasts = implicitCasts; 288 analysisOptions.implicitCasts = implicitCasts;
289 analysisOptions.implicitDynamic = implicitDynamic; 289 analysisOptions.implicitDynamic = implicitDynamic;
290 analysisOptions.nonnullableTypes = nonnullableTypes; 290 analysisOptions.nonnullableTypes = nonnullableTypes;
291 analysisOptions.enableSuperMixins = superMixins;
291 292
292 var mockSdk = new MockSdk(resourceProvider: _resourceProvider); 293 var mockSdk = new MockSdk(resourceProvider: _resourceProvider);
293 mockSdk.context.analysisOptions = analysisOptions; 294 mockSdk.context.analysisOptions = analysisOptions;
294 295
295 SourceFactory sourceFactory; 296 SourceFactory sourceFactory;
296 { 297 {
297 var uriResolver = new _TestUriResolver(_resourceProvider); 298 var uriResolver = new _TestUriResolver(_resourceProvider);
298 sourceFactory = 299 sourceFactory =
299 new SourceFactory([new DartUriResolver(mockSdk), uriResolver]); 300 new SourceFactory([new DartUriResolver(mockSdk), uriResolver]);
300 } 301 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 _expectErrors(analysisOptions, analysisResult.unit, errors); 357 _expectErrors(analysisOptions, analysisResult.unit, errors);
357 } 358 }
358 } 359 }
359 360
360 return mainUnit; 361 return mainUnit;
361 } 362 }
362 363
363 /// Adds a file using [addFile] and calls [check]. 364 /// Adds a file using [addFile] and calls [check].
364 /// 365 ///
365 /// Also returns the resolved compilation unit. 366 /// Also returns the resolved compilation unit.
366 Future<CompilationUnit> checkFile(String content) async { 367 Future<CompilationUnit> checkFile(String content,
368 {bool declarationCasts: true,
369 bool implicitCasts: true,
370 bool implicitDynamic: true,
371 List<String> nonnullableTypes: AnalysisOptionsImpl.NONNULLABLE_TYPES,
372 bool superMixins: false}) async {
367 addFile(content); 373 addFile(content);
368 return check(); 374 return check(
375 declarationCasts: declarationCasts,
376 implicitCasts: implicitCasts,
377 implicitDynamic: implicitDynamic,
378 nonnullableTypes: nonnullableTypes,
379 superMixins: superMixins);
369 } 380 }
370 381
371 void setUp() { 382 void setUp() {
372 AnalysisEngine.instance.processRequiredPlugins(); 383 AnalysisEngine.instance.processRequiredPlugins();
373 } 384 }
374 385
375 void tearDown() { 386 void tearDown() {
376 // This is a sanity check, in case only addFile is called. 387 // This is a sanity check, in case only addFile is called.
377 expect(_checkCalled, true, reason: 'must call check() method in test case'); 388 expect(_checkCalled, true, reason: 'must call check() method in test case');
378 _context?.dispose(); 389 _context?.dispose();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 @override 485 @override
475 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 486 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
476 if (uri.scheme == 'package') { 487 if (uri.scheme == 'package') {
477 return (provider.getResource( 488 return (provider.getResource(
478 provider.convertPath('/packages/' + uri.path)) as File) 489 provider.convertPath('/packages/' + uri.path)) as File)
479 .createSource(uri); 490 .createSource(uri);
480 } 491 }
481 return super.resolveAbsolute(uri, actualUri); 492 return super.resolveAbsolute(uri, actualUri);
482 } 493 }
483 } 494 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/strong/inferred_type_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698