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.non_error_resolver_test; | 5 library engine.non_error_resolver_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; |
9 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 11 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
11 import 'package:analyzer/src/generated/source_io.dart'; | 12 import 'package:analyzer/src/generated/source_io.dart'; |
12 import 'package:unittest/unittest.dart' as _ut; | 13 import 'package:unittest/unittest.dart' as _ut; |
13 | 14 |
14 import '../reflective_tests.dart'; | 15 import '../reflective_tests.dart'; |
15 import 'resolver_test.dart'; | 16 import 'resolver_test.dart'; |
16 import 'test_support.dart'; | 17 import 'test_support.dart'; |
17 | 18 |
18 main() { | 19 main() { |
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2300 | 2301 |
2301 void test_invalidAssignment_defaultValue_optional() { | 2302 void test_invalidAssignment_defaultValue_optional() { |
2302 Source source = addSource(r''' | 2303 Source source = addSource(r''' |
2303 f([String x = '0']) { | 2304 f([String x = '0']) { |
2304 }'''); | 2305 }'''); |
2305 resolve(source); | 2306 resolve(source); |
2306 assertNoErrors(source); | 2307 assertNoErrors(source); |
2307 verify([source]); | 2308 verify([source]); |
2308 } | 2309 } |
2309 | 2310 |
| 2311 void test_invalidAssignment_ifNullAssignment_compatibleType() { |
| 2312 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2313 options.enableNullAwareOperators = true; |
| 2314 resetWithOptions(options); |
| 2315 Source source = addSource(''' |
| 2316 void f(int i) { |
| 2317 num n; |
| 2318 n ??= i; |
| 2319 } |
| 2320 '''); |
| 2321 resolve(source); |
| 2322 assertNoErrors(source); |
| 2323 verify([source]); |
| 2324 } |
| 2325 |
| 2326 void test_invalidAssignment_ifNullAssignment_sameType() { |
| 2327 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2328 options.enableNullAwareOperators = true; |
| 2329 resetWithOptions(options); |
| 2330 Source source = addSource(''' |
| 2331 void f(int i) { |
| 2332 int j; |
| 2333 j ??= i; |
| 2334 } |
| 2335 '''); |
| 2336 resolve(source); |
| 2337 assertNoErrors(source); |
| 2338 verify([source]); |
| 2339 } |
| 2340 |
2310 void test_invalidAssignment_implicitlyImplementFunctionViaCall_1() { | 2341 void test_invalidAssignment_implicitlyImplementFunctionViaCall_1() { |
2311 // 18341 | 2342 // 18341 |
2312 // | 2343 // |
2313 // This test and | 2344 // This test and |
2314 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()' | 2345 // 'test_invalidAssignment_implicitlyImplementFunctionViaCall_2()' |
2315 // are closely related: here we see that 'I' checks as a subtype of | 2346 // are closely related: here we see that 'I' checks as a subtype of |
2316 // 'IntToInt'. | 2347 // 'IntToInt'. |
2317 Source source = addSource(r''' | 2348 Source source = addSource(r''' |
2318 class I { | 2349 class I { |
2319 int call(int x) => 0; | 2350 int call(int x) => 0; |
(...skipping 3071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5391 resolve(source); | 5422 resolve(source); |
5392 assertNoErrors(source); | 5423 assertNoErrors(source); |
5393 verify([source]); | 5424 verify([source]); |
5394 reset(); | 5425 reset(); |
5395 } | 5426 } |
5396 | 5427 |
5397 void _check_wrongNumberOfParametersForOperator1(String name) { | 5428 void _check_wrongNumberOfParametersForOperator1(String name) { |
5398 _check_wrongNumberOfParametersForOperator(name, "a"); | 5429 _check_wrongNumberOfParametersForOperator(name, "a"); |
5399 } | 5430 } |
5400 } | 5431 } |
OLD | NEW |