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 /// General type checking tests | 5 /// General type checking tests |
6 library dev_compiler.test.checker_test; | 6 library dev_compiler.test.checker_test; |
7 | 7 |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 | 9 |
10 import 'package:dev_compiler/src/testing.dart'; | 10 import 'package:dev_compiler/src/testing.dart'; |
11 | 11 |
12 import '../test_util.dart'; | 12 import '../test_util.dart'; |
13 | 13 |
14 void main() { | 14 void main() { |
15 configureTest(); | 15 configureTest(); |
16 | 16 |
17 test('conversion and dynamic invoke', () { | 17 test('conversion and dynamic invoke', () { |
18 testChecker({ | 18 testChecker({ |
| 19 '/helper.dart': ''' |
| 20 dynamic toString = (int x) => x + 42; |
| 21 dynamic hashCode = "hello"; |
| 22 ''', |
19 '/main.dart': ''' | 23 '/main.dart': ''' |
| 24 import 'helper.dart' as helper; |
| 25 |
20 class A { | 26 class A { |
21 String x = "hello world"; | 27 String x = "hello world"; |
22 | 28 |
23 void baz1(y) => x + y; | 29 void baz1(y) => x + y; |
24 static baz2(y) => y + y; | 30 static baz2(y) => y + y; |
25 } | 31 } |
26 | 32 |
27 void foo(String str) { | 33 void foo(String str) { |
28 print(str); | 34 print(str); |
29 } | 35 } |
(...skipping 21 matching lines...) Expand all Loading... |
51 (/*warning:DynamicInvoke*/f3("hello")); | 57 (/*warning:DynamicInvoke*/f3("hello")); |
52 (/*warning:DynamicInvoke*/f3(42)); | 58 (/*warning:DynamicInvoke*/f3(42)); |
53 StrFun f4 = foo; | 59 StrFun f4 = foo; |
54 f4("hello"); | 60 f4("hello"); |
55 a.baz1("hello"); | 61 a.baz1("hello"); |
56 var b1 = a.baz1; | 62 var b1 = a.baz1; |
57 (/*warning:DynamicInvoke*/b1("hello")); | 63 (/*warning:DynamicInvoke*/b1("hello")); |
58 A.baz2("hello"); | 64 A.baz2("hello"); |
59 var b2 = A.baz2; | 65 var b2 = A.baz2; |
60 (/*warning:DynamicInvoke*/b2("hello")); | 66 (/*warning:DynamicInvoke*/b2("hello")); |
| 67 |
| 68 dynamic a1 = new A(); |
| 69 (/*warning:DynamicInvoke*/a1.x); |
| 70 a1.toString(); |
| 71 a1.hashCode; |
| 72 |
| 73 dynamic toString = () => null; |
| 74 (/*warning:DynamicInvoke*/toString()); |
| 75 |
| 76 (/*warning:DynamicInvoke*/helper.toString()); |
| 77 int hashCode = /*info:DynamicCast*/helper.hashCode; |
61 ''' | 78 ''' |
62 }); | 79 }); |
63 }); | 80 }); |
64 | 81 |
65 test('Primitives', () { | 82 test('Primitives', () { |
66 testChecker({ | 83 testChecker({ |
67 '/main.dart': ''' | 84 '/main.dart': ''' |
68 int /*severe:InvalidVariableDeclaration*/a; | 85 int /*severe:InvalidVariableDeclaration*/a; |
69 double /*severe:InvalidVariableDeclaration*/b; | 86 double /*severe:InvalidVariableDeclaration*/b; |
70 num c; | 87 num c; |
(...skipping 2729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 f = bar as II2D; | 2817 f = bar as II2D; |
2801 f = bar as DD2I; | 2818 f = bar as DD2I; |
2802 f = bar as DI2D; | 2819 f = bar as DI2D; |
2803 f = bar as ID2D; | 2820 f = bar as ID2D; |
2804 f = bar as DD2D; | 2821 f = bar as DD2D; |
2805 } | 2822 } |
2806 ''' | 2823 ''' |
2807 }); | 2824 }); |
2808 }); | 2825 }); |
2809 } | 2826 } |
OLD | NEW |