| 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 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 /// General type checking tests | 7 /// General type checking tests |
| 8 library analyzer.test.src.task.strong.checker_test; | 8 library analyzer.test.src.task.strong.checker_test; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 bar(y: 1, x: 2, z: 3); | 1425 bar(y: 1, x: 2, z: 3); |
| 1426 String x = bar(z: '1', x: '2', y: '3'); | 1426 String x = bar(z: '1', x: '2', y: '3'); |
| 1427 bar(y: 1); | 1427 bar(y: 1); |
| 1428 x = bar(x: '1', z: 42); | 1428 x = bar(x: '1', z: 42); |
| 1429 x = /*severe:STATIC_TYPE_ERROR*/bar(y: 1, x: 2, z: 3); | 1429 x = /*severe:STATIC_TYPE_ERROR*/bar(y: 1, x: 2, z: 3); |
| 1430 x = /*severe:STATIC_TYPE_ERROR*/bar(x: 1); | 1430 x = /*severe:STATIC_TYPE_ERROR*/bar(x: 1); |
| 1431 } | 1431 } |
| 1432 ''' | 1432 ''' |
| 1433 }); | 1433 }); |
| 1434 | 1434 |
| 1435 testChecker('type promotion from dynamic', { |
| 1436 '/main.dart': r''' |
| 1437 f() { |
| 1438 dynamic x; |
| 1439 if (x is int) { |
| 1440 int y = x; |
| 1441 String z = /*severe:STATIC_TYPE_ERROR*/x; |
| 1442 } |
| 1443 } |
| 1444 g() { |
| 1445 Object x; |
| 1446 if (x is int) { |
| 1447 int y = x; |
| 1448 String z = /*severe:STATIC_TYPE_ERROR*/x; |
| 1449 } |
| 1450 } |
| 1451 ''' |
| 1452 }); |
| 1453 |
| 1435 testChecker('unary operators', { | 1454 testChecker('unary operators', { |
| 1436 '/main.dart': ''' | 1455 '/main.dart': ''' |
| 1437 class A { | 1456 class A { |
| 1438 A operator ~() {} | 1457 A operator ~() {} |
| 1439 A operator +(int x) {} | 1458 A operator +(int x) {} |
| 1440 A operator -(int x) {} | 1459 A operator -(int x) {} |
| 1441 A operator -() {} | 1460 A operator -() {} |
| 1442 } | 1461 } |
| 1443 | 1462 |
| 1444 foo() => new A(); | 1463 foo() => new A(); |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2533 | 2552 |
| 2534 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2553 baz1() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2535 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } | 2554 Iterable baz2() sync* { yield* (/*info:DYNAMIC_CAST*/x); } |
| 2536 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} | 2555 Iterable<int> baz3() sync* { yield* (/*warning:DOWN_CAST_COMPOSITE*/x);
} |
| 2537 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } | 2556 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } |
| 2538 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } | 2557 Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/ne
w Iterable()); } |
| 2539 ''' | 2558 ''' |
| 2540 }); | 2559 }); |
| 2541 }); | 2560 }); |
| 2542 } | 2561 } |
| OLD | NEW |