| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 set b(y) => voidFn(); | 70 set b(y) => voidFn(); |
| 71 void set c(y) => /*warning:RETURN_OF_INVALID_TYPE*/4; | 71 void set c(y) => /*warning:RETURN_OF_INVALID_TYPE*/4; |
| 72 void set d(y) => voidFn(); | 72 void set d(y) => voidFn(); |
| 73 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4; | 73 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4; |
| 74 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) => /*warning:RETURN_O
F_INVALID_TYPE*/voidFn(); | 74 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) => /*warning:RETURN_O
F_INVALID_TYPE*/voidFn(); |
| 75 set g(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} | 75 set g(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} |
| 76 void set h(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} | 76 void set h(y) {return /*warning:RETURN_OF_INVALID_TYPE*/4;} |
| 77 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;} | 77 /*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;} |
| 78 } | 78 } |
| 79 '''); | 79 '''); |
| 80 | |
| 81 }); | 80 }); |
| 82 | 81 |
| 83 test('if/for/do/while statements use boolean conversion', () { | 82 test('if/for/do/while statements use boolean conversion', () { |
| 84 checkFile(''' | 83 checkFile(''' |
| 85 main() { | 84 main() { |
| 86 dynamic dyn = 42; | 85 dynamic dyn = 42; |
| 87 Object obj = 42; | 86 Object obj = 42; |
| 88 int i = 42; | 87 int i = 42; |
| 89 bool b = false; | 88 bool b = false; |
| 90 | 89 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 f = /*warning:DOWN_CAST_COMPOSITE*/top; | 678 f = /*warning:DOWN_CAST_COMPOSITE*/top; |
| 680 f = /*warning:DOWN_CAST_COMPOSITE*/left; | 679 f = /*warning:DOWN_CAST_COMPOSITE*/left; |
| 681 f = /*warning:DOWN_CAST_COMPOSITE*/right; | 680 f = /*warning:DOWN_CAST_COMPOSITE*/right; |
| 682 f = bot; | 681 f = bot; |
| 683 } | 682 } |
| 684 } | 683 } |
| 685 '''); | 684 '''); |
| 686 }); | 685 }); |
| 687 | 686 |
| 688 test('dynamic - known functions', () { | 687 test('dynamic - known functions', () { |
| 689 | |
| 690 // Our lattice should look like this: | 688 // Our lattice should look like this: |
| 691 // | 689 // |
| 692 // | 690 // |
| 693 // Bot -> Top | 691 // Bot -> Top |
| 694 // / \ | 692 // / \ |
| 695 // A -> Top Bot -> A | 693 // A -> Top Bot -> A |
| 696 // / \ / | 694 // / \ / |
| 697 // Top -> Top A -> A | 695 // Top -> Top A -> A |
| 698 // \ / | 696 // \ / |
| 699 // Top -> A | 697 // Top -> A |
| (...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 | 2995 |
| 2998 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 2996 baz1() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 2999 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } | 2997 Iterable baz2() sync* { yield* /*info:DYNAMIC_CAST*/x; } |
| 3000 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } | 2998 Iterable<int> baz3() sync* { yield* /*warning:DOWN_CAST_COMPOSITE*/x; } |
| 3001 Iterable<int> baz4() sync* { yield* bar3(); } | 2999 Iterable<int> baz4() sync* { yield* bar3(); } |
| 3002 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new
List(); } | 3000 Iterable<int> baz5() sync* { yield* /*info:INFERRED_TYPE_ALLOCATION*/new
List(); } |
| 3003 '''); | 3001 '''); |
| 3004 }); | 3002 }); |
| 3005 }); | 3003 }); |
| 3006 } | 3004 } |
| OLD | NEW |