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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test_case.dart

Issue 2626653002: Remove computeLibrarySourceErrors(). (Closed)
Patch Set: Created 3 years, 11 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library analyzer.test.generated.resolver_test_case; 5 library analyzer.test.generated.resolver_test_case;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 395 }
396 396
397 /** 397 /**
398 * Asserts that [code] verifies, but has errors with the given error codes. 398 * Asserts that [code] verifies, but has errors with the given error codes.
399 * 399 *
400 * Like [assertErrors], but takes a string of source code. 400 * Like [assertErrors], but takes a string of source code.
401 */ 401 */
402 // TODO(rnystrom): Use this in more tests that have the same structure. 402 // TODO(rnystrom): Use this in more tests that have the same structure.
403 void assertErrorsInCode(String code, List<ErrorCode> errors) { 403 void assertErrorsInCode(String code, List<ErrorCode> errors) {
404 Source source = addSource(code); 404 Source source = addSource(code);
405 computeLibrarySourceErrors(source);
406 assertErrors(source, errors); 405 assertErrors(source, errors);
407 verify([source]); 406 verify([source]);
408 } 407 }
409 408
410 /** 409 /**
411 * Asserts that [code] has errors with the given error codes. 410 * Asserts that [code] has errors with the given error codes.
412 * 411 *
413 * Like [assertErrors], but takes a string of source code. 412 * Like [assertErrors], but takes a string of source code.
414 */ 413 */
415 void assertErrorsInUnverifiedCode(String code, List<ErrorCode> errors) { 414 void assertErrorsInUnverifiedCode(String code, List<ErrorCode> errors) {
416 Source source = addSource(code); 415 Source source = addSource(code);
417 computeLibrarySourceErrors(source);
418 assertErrors(source, errors); 416 assertErrors(source, errors);
419 } 417 }
420 418
421 /** 419 /**
422 * Assert that no errors have been reported against the given source. 420 * Assert that no errors have been reported against the given source.
423 * 421 *
424 * @param source the source against which no errors should have been reported 422 * @param source the source against which no errors should have been reported
425 * @throws AnalysisException if the reported errors could not be computed 423 * @throws AnalysisException if the reported errors could not be computed
426 * @throws AssertionFailedError if any errors have been reported 424 * @throws AssertionFailedError if any errors have been reported
427 */ 425 */
428 void assertNoErrors(Source source) { 426 void assertNoErrors(Source source) {
429 assertErrors(source); 427 assertErrors(source);
430 } 428 }
431 429
432 /** 430 /**
433 * Asserts that [code] has no errors or warnings. 431 * Asserts that [code] has no errors or warnings.
434 */ 432 */
435 // TODO(rnystrom): Use this in more tests that have the same structure. 433 // TODO(rnystrom): Use this in more tests that have the same structure.
436 void assertNoErrorsInCode(String code) { 434 void assertNoErrorsInCode(String code) {
437 Source source = addSource(code); 435 Source source = addSource(code);
438 computeLibrarySourceErrors(source);
439 assertNoErrors(source); 436 assertNoErrors(source);
440 verify([source]); 437 verify([source]);
441 } 438 }
442 439
443 /** 440 /**
444 * @param code the code that assigns the value to the variable "v", no matter how. We check that 441 * @param code the code that assigns the value to the variable "v", no matter how. We check that
445 * "v" has expected static and propagated type. 442 * "v" has expected static and propagated type.
446 */ 443 */
447 void assertPropagatedAssignedType(String code, DartType expectedStaticType, 444 void assertPropagatedAssignedType(String code, DartType expectedStaticType,
448 DartType expectedPropagatedType) { 445 DartType expectedPropagatedType) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 * Change the contents of the given [source] to the given [contents]. 490 * Change the contents of the given [source] to the given [contents].
494 */ 491 */
495 void changeSource(Source source, String contents) { 492 void changeSource(Source source, String contents) {
496 analysisContext2.setContents(source, contents); 493 analysisContext2.setContents(source, contents);
497 ChangeSet changeSet = new ChangeSet(); 494 ChangeSet changeSet = new ChangeSet();
498 changeSet.changedSource(source); 495 changeSet.changedSource(source);
499 analysisContext2.applyChanges(changeSet); 496 analysisContext2.applyChanges(changeSet);
500 } 497 }
501 498
502 /** 499 /**
503 * Computes errors for the given [librarySource].
504 * This assumes that the given [librarySource] and its parts have already
505 * been added to the content provider using the method [addNamedSource].
506 */
507 void computeLibrarySourceErrors(Source librarySource) {
508 analysisContext.computeErrors(librarySource);
509 }
510
511 /**
512 * Create a library element that represents a library named `"test"` containin g a single 500 * Create a library element that represents a library named `"test"` containin g a single
513 * empty compilation unit. 501 * empty compilation unit.
514 * 502 *
515 * @return the library element that was created 503 * @return the library element that was created
516 */ 504 */
517 LibraryElementImpl createDefaultTestLibrary() => 505 LibraryElementImpl createDefaultTestLibrary() =>
518 createTestLibrary(AnalysisContextFactory.contextWithCore(), "test"); 506 createTestLibrary(AnalysisContextFactory.contextWithCore(), "test");
519 507
520 /** 508 /**
521 * Create a source object representing a file with the given [fileName] and 509 * Create a source object representing a file with the given [fileName] and
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. 832 * text. Otherwise, [expected] is used directly a [Matcher] to match the type.
845 */ 833 */
846 _expectType(DartType type, expected) { 834 _expectType(DartType type, expected) {
847 if (expected is String) { 835 if (expected is String) {
848 expect(type.toString(), expected); 836 expect(type.toString(), expected);
849 } else { 837 } else {
850 expect(type, expected); 838 expect(type, expected);
851 } 839 }
852 } 840 }
853 } 841 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/test/generated/simple_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698