| 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 engine.all_the_rest_test; | 5 library engine.all_the_rest_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/physical_file_system.dart'; | 7 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| 9 import 'package:analyzer/src/generated/constant.dart'; | 9 import 'package:analyzer/src/generated/constant.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import 'package:analyzer/src/generated/source_io.dart'; | 23 import 'package:analyzer/src/generated/source_io.dart'; |
| 24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 25 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 25 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 26 import 'package:analyzer/src/generated/testing/html_factory.dart'; | 26 import 'package:analyzer/src/generated/testing/html_factory.dart'; |
| 27 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 27 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 28 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 28 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 29 import 'package:analyzer/src/generated/utilities_collection.dart'; | 29 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 30 import 'package:analyzer/src/generated/utilities_dart.dart'; | 30 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 31 import 'package:analyzer/src/task/dart.dart'; | 31 import 'package:analyzer/src/task/dart.dart'; |
| 32 import 'package:path/path.dart'; | 32 import 'package:path/path.dart'; |
| 33 import 'package:source_span/source_span.dart'; |
| 33 import 'package:unittest/unittest.dart'; | 34 import 'package:unittest/unittest.dart'; |
| 34 | 35 |
| 35 import '../reflective_tests.dart'; | 36 import '../reflective_tests.dart'; |
| 36 import '../utils.dart'; | 37 import '../utils.dart'; |
| 37 import 'engine_test.dart'; | 38 import 'engine_test.dart'; |
| 38 import 'parser_test.dart'; | 39 import 'parser_test.dart'; |
| 39 import 'resolver_test.dart'; | 40 import 'resolver_test.dart'; |
| 40 import 'test_support.dart'; | 41 import 'test_support.dart'; |
| 41 | 42 |
| 42 main() { | 43 main() { |
| (...skipping 7284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7327 new NonExistingSource( | 7328 new NonExistingSource( |
| 7328 '/test.dart', toUri('/test.dart'), UriKind.FILE_URI)); | 7329 '/test.dart', toUri('/test.dart'), UriKind.FILE_URI)); |
| 7329 reporter.reportErrorForElement( | 7330 reporter.reportErrorForElement( |
| 7330 StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER, | 7331 StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER, |
| 7331 element, | 7332 element, |
| 7332 ['A']); | 7333 ['A']); |
| 7333 AnalysisError error = listener.errors[0]; | 7334 AnalysisError error = listener.errors[0]; |
| 7334 expect(error.offset, element.nameOffset); | 7335 expect(error.offset, element.nameOffset); |
| 7335 } | 7336 } |
| 7336 | 7337 |
| 7338 void test_reportErrorForSpan() { |
| 7339 GatheringErrorListener listener = new GatheringErrorListener(); |
| 7340 ErrorReporter reporter = new ErrorReporter(listener, new TestSource()); |
| 7341 |
| 7342 var src = ''' |
| 7343 foo: bar |
| 7344 zap: baz |
| 7345 '''; |
| 7346 |
| 7347 int offset = src.indexOf('baz'); |
| 7348 int length = 'baz'.length; |
| 7349 |
| 7350 SourceSpan span = new SourceFile(src).span(offset, offset + length); |
| 7351 |
| 7352 reporter.reportErrorForSpan( |
| 7353 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION, span, ['test', 'zap']); |
| 7354 expect(listener.errors, hasLength(1)); |
| 7355 expect(listener.errors.first.offset, offset); |
| 7356 expect(listener.errors.first.length, length); |
| 7357 } |
| 7358 |
| 7337 void test_reportTypeErrorForNode_differentNames() { | 7359 void test_reportTypeErrorForNode_differentNames() { |
| 7338 DartType firstType = createType("/test1.dart", "A"); | 7360 DartType firstType = createType("/test1.dart", "A"); |
| 7339 DartType secondType = createType("/test2.dart", "B"); | 7361 DartType secondType = createType("/test2.dart", "B"); |
| 7340 GatheringErrorListener listener = new GatheringErrorListener(); | 7362 GatheringErrorListener listener = new GatheringErrorListener(); |
| 7341 ErrorReporter reporter = | 7363 ErrorReporter reporter = |
| 7342 new ErrorReporter(listener, firstType.element.source); | 7364 new ErrorReporter(listener, firstType.element.source); |
| 7343 reporter.reportTypeErrorForNode( | 7365 reporter.reportTypeErrorForNode( |
| 7344 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | 7366 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, |
| 7345 AstFactory.identifier3("x"), | 7367 AstFactory.identifier3("x"), |
| 7346 [firstType, secondType]); | 7368 [firstType, secondType]); |
| (...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9391 if (_expectedExternalScriptName == null) { | 9413 if (_expectedExternalScriptName == null) { |
| 9392 expect(scriptSource, isNull, reason: "script $scriptIndex"); | 9414 expect(scriptSource, isNull, reason: "script $scriptIndex"); |
| 9393 } else { | 9415 } else { |
| 9394 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); | 9416 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); |
| 9395 String actualExternalScriptName = scriptSource.shortName; | 9417 String actualExternalScriptName = scriptSource.shortName; |
| 9396 expect(actualExternalScriptName, _expectedExternalScriptName, | 9418 expect(actualExternalScriptName, _expectedExternalScriptName, |
| 9397 reason: "script $scriptIndex"); | 9419 reason: "script $scriptIndex"); |
| 9398 } | 9420 } |
| 9399 } | 9421 } |
| 9400 } | 9422 } |
| OLD | NEW |