OLD | NEW |
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 library test.src.task.dart_test; | 5 library test.src.task.dart_test; |
6 | 6 |
7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
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'; |
11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
12 show AnalysisOptionsImpl, CacheState; | 12 show AnalysisOptionsImpl, CacheState; |
13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
14 import 'package:analyzer/src/generated/resolver.dart'; | 14 import 'package:analyzer/src/generated/resolver.dart'; |
15 import 'package:analyzer/src/generated/scanner.dart'; | 15 import 'package:analyzer/src/generated/scanner.dart'; |
16 import 'package:analyzer/src/generated/sdk.dart'; | 16 import 'package:analyzer/src/generated/sdk.dart'; |
17 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
18 import 'package:analyzer/src/services/lint.dart'; | 18 import 'package:analyzer/src/services/lint.dart'; |
19 import 'package:analyzer/src/task/dart.dart'; | 19 import 'package:analyzer/src/task/dart.dart'; |
20 import 'package:analyzer/src/task/html.dart'; | 20 import 'package:analyzer/src/task/html.dart'; |
| 21 import 'package:analyzer/src/task/strong/info.dart'; |
21 import 'package:analyzer/task/dart.dart'; | 22 import 'package:analyzer/task/dart.dart'; |
22 import 'package:analyzer/task/general.dart'; | 23 import 'package:analyzer/task/general.dart'; |
23 import 'package:analyzer/task/model.dart'; | 24 import 'package:analyzer/task/model.dart'; |
24 import 'package:unittest/unittest.dart'; | 25 import 'package:unittest/unittest.dart'; |
25 | 26 |
26 import '../../generated/resolver_test.dart'; | 27 import '../../generated/resolver_test.dart'; |
27 import '../../generated/test_support.dart'; | 28 import '../../generated/test_support.dart'; |
28 import '../../reflective_tests.dart'; | 29 import '../../reflective_tests.dart'; |
29 import '../../utils.dart'; | 30 import '../../utils.dart'; |
30 import '../context/abstract_context.dart'; | 31 import '../context/abstract_context.dart'; |
(...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 '/test.dart', | 4009 '/test.dart', |
4009 ''' | 4010 ''' |
4010 const topLevel = 3; | 4011 const topLevel = 3; |
4011 class C { | 4012 class C { |
4012 String field = topLevel; | 4013 String field = topLevel; |
4013 } | 4014 } |
4014 '''); | 4015 '''); |
4015 computeResult(new LibrarySpecificUnit(source, source), VERIFY_ERRORS); | 4016 computeResult(new LibrarySpecificUnit(source, source), VERIFY_ERRORS); |
4016 // validate | 4017 // validate |
4017 _fillErrorListener(VERIFY_ERRORS); | 4018 _fillErrorListener(VERIFY_ERRORS); |
4018 errorListener.assertErrorsWithCodes( | 4019 |
4019 <ErrorCode>[StaticTypeWarningCode.INVALID_ASSIGNMENT]); | 4020 // TODO(jmesserly): DDC errors do not hash correctly. |
| 4021 // TODO(jmesserly): also we have a duplicate error message here. |
| 4022 var errors = errorListener.errors; |
| 4023 expect(errors.length, 2); |
| 4024 expect(errors[0].errorCode.name, 'dev_compiler.StaticTypeError'); |
| 4025 expect(errors[0].message, |
| 4026 'Type check failed: topLevel (int) is not of type String'); |
| 4027 expect(errors[1].errorCode, StaticTypeWarningCode.INVALID_ASSIGNMENT); |
4020 } | 4028 } |
4021 | 4029 |
4022 test_perform_verifyError() { | 4030 test_perform_verifyError() { |
4023 Source source = newSource( | 4031 Source source = newSource( |
4024 '/test.dart', | 4032 '/test.dart', |
4025 ''' | 4033 ''' |
4026 main() { | 4034 main() { |
4027 if (42) { | 4035 if (42) { |
4028 print('Not bool!'); | 4036 print('Not bool!'); |
4029 } | 4037 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4248 /** | 4256 /** |
4249 * Fill [errorListener] with [result] errors in the current [task]. | 4257 * Fill [errorListener] with [result] errors in the current [task]. |
4250 */ | 4258 */ |
4251 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 4259 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
4252 List<AnalysisError> errors = task.outputs[result]; | 4260 List<AnalysisError> errors = task.outputs[result]; |
4253 expect(errors, isNotNull, reason: result.name); | 4261 expect(errors, isNotNull, reason: result.name); |
4254 errorListener = new GatheringErrorListener(); | 4262 errorListener = new GatheringErrorListener(); |
4255 errorListener.addAll(errors); | 4263 errorListener.addAll(errors); |
4256 } | 4264 } |
4257 } | 4265 } |
OLD | NEW |