OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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; | 5 library analyzer.test.generated.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 8353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8364 errorCode == HintCode.UNUSED_CATCH_STACK || | 8364 errorCode == HintCode.UNUSED_CATCH_STACK || |
8365 errorCode == HintCode.UNUSED_LOCAL_VARIABLE)) { | 8365 errorCode == HintCode.UNUSED_LOCAL_VARIABLE)) { |
8366 continue; | 8366 continue; |
8367 } | 8367 } |
8368 errorListener.onError(error); | 8368 errorListener.onError(error); |
8369 } | 8369 } |
8370 errorListener.assertErrorsWithCodes(expectedErrorCodes); | 8370 errorListener.assertErrorsWithCodes(expectedErrorCodes); |
8371 } | 8371 } |
8372 | 8372 |
8373 /** | 8373 /** |
| 8374 * Asserts that [code] has errors with the given error codes. |
| 8375 * |
| 8376 * Like [assertErrors], but takes a string of source code. |
| 8377 */ |
| 8378 // TODO(rnystrom): Use this in more tests that have the same structure. |
| 8379 void assertErrorsInCode(String code, List<ErrorCode> errors) { |
| 8380 Source source = addSource(code); |
| 8381 computeLibrarySourceErrors(source); |
| 8382 assertErrors(source, errors); |
| 8383 verify([source]); |
| 8384 } |
| 8385 |
| 8386 /** |
8374 * Assert that no errors have been reported against the given source. | 8387 * Assert that no errors have been reported against the given source. |
8375 * | 8388 * |
8376 * @param source the source against which no errors should have been reported | 8389 * @param source the source against which no errors should have been reported |
8377 * @throws AnalysisException if the reported errors could not be computed | 8390 * @throws AnalysisException if the reported errors could not be computed |
8378 * @throws AssertionFailedError if any errors have been reported | 8391 * @throws AssertionFailedError if any errors have been reported |
8379 */ | 8392 */ |
8380 void assertNoErrors(Source source) { | 8393 void assertNoErrors(Source source) { |
8381 assertErrors(source); | 8394 assertErrors(source); |
8382 } | 8395 } |
8383 | 8396 |
8384 /** | 8397 /** |
| 8398 * Asserts that [code] has no errors or warnings. |
| 8399 */ |
| 8400 // TODO(rnystrom): Use this in more tests that have the same structure. |
| 8401 void assertNoErrorsInCode(String code) { |
| 8402 Source source = addSource(code); |
| 8403 computeLibrarySourceErrors(source); |
| 8404 assertNoErrors(source); |
| 8405 verify([source]); |
| 8406 } |
| 8407 |
| 8408 /** |
8385 * Cache the source file content in the source factory but don't add the sourc
e to the analysis | 8409 * Cache the source file content in the source factory but don't add the sourc
e to the analysis |
8386 * context. The file path should be absolute. | 8410 * context. The file path should be absolute. |
8387 * | 8411 * |
8388 * @param filePath the path of the file being cached | 8412 * @param filePath the path of the file being cached |
8389 * @param contents the contents to be returned by the content provider for the
specified file | 8413 * @param contents the contents to be returned by the content provider for the
specified file |
8390 * @return the source object representing the cached file | 8414 * @return the source object representing the cached file |
8391 */ | 8415 */ |
8392 Source cacheSource(String filePath, String contents) { | 8416 Source cacheSource(String filePath, String contents) { |
8393 Source source = new FileBasedSource(FileUtilities2.createFile(filePath)); | 8417 Source source = new FileBasedSource(FileUtilities2.createFile(filePath)); |
8394 analysisContext2.setContents(source, contents); | 8418 analysisContext2.setContents(source, contents); |
(...skipping 9079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17474 | 17498 |
17475 void _resolveTestUnit(String code) { | 17499 void _resolveTestUnit(String code) { |
17476 testCode = code; | 17500 testCode = code; |
17477 testSource = addSource(testCode); | 17501 testSource = addSource(testCode); |
17478 LibraryElement library = resolve2(testSource); | 17502 LibraryElement library = resolve2(testSource); |
17479 assertNoErrors(testSource); | 17503 assertNoErrors(testSource); |
17480 verify([testSource]); | 17504 verify([testSource]); |
17481 testUnit = resolveCompilationUnit(testSource, library); | 17505 testUnit = resolveCompilationUnit(testSource, library); |
17482 } | 17506 } |
17483 } | 17507 } |
OLD | NEW |