| 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'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 void baz1(y) => x + y; | 23 void baz1(y) => x + y; |
| 24 static baz2(y) => y + y; | 24 static baz2(y) => y + y; |
| 25 } | 25 } |
| 26 | 26 |
| 27 void foo(String str) { | 27 void foo(String str) { |
| 28 print(str); | 28 print(str); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void bar(a) { | 31 void bar(a) { |
| 32 foo(/*info:DynamicCast,warning:DynamicInvoke*/a.x); | 32 foo(/*info:DynamicCast,info:DynamicInvoke*/a.x); |
| 33 } | 33 } |
| 34 | 34 |
| 35 typedef DynFun(x); | 35 typedef DynFun(x); |
| 36 typedef StrFun(String x); | 36 typedef StrFun(String x); |
| 37 | 37 |
| 38 var bar1 = bar; | 38 var bar1 = bar; |
| 39 | 39 |
| 40 void main() { | 40 void main() { |
| 41 var a = new A(); | 41 var a = new A(); |
| 42 bar(a); | 42 bar(a); |
| 43 (/*warning:DynamicInvoke*/bar1(a)); | 43 (/*info:DynamicInvoke*/bar1(a)); |
| 44 var b = bar; | 44 var b = bar; |
| 45 (/*warning:DynamicInvoke*/b(a)); | 45 (/*info:DynamicInvoke*/b(a)); |
| 46 var f1 = foo; | 46 var f1 = foo; |
| 47 f1("hello"); | 47 f1("hello"); |
| 48 dynamic f2 = foo; | 48 dynamic f2 = foo; |
| 49 (/*warning:DynamicInvoke*/f2("hello")); | 49 (/*info:DynamicInvoke*/f2("hello")); |
| 50 DynFun f3 = foo; | 50 DynFun f3 = foo; |
| 51 (/*warning:DynamicInvoke*/f3("hello")); | 51 (/*info:DynamicInvoke*/f3("hello")); |
| 52 (/*warning:DynamicInvoke*/f3(42)); | 52 (/*info:DynamicInvoke*/f3(42)); |
| 53 StrFun f4 = foo; | 53 StrFun f4 = foo; |
| 54 f4("hello"); | 54 f4("hello"); |
| 55 a.baz1("hello"); | 55 a.baz1("hello"); |
| 56 var b1 = a.baz1; | 56 var b1 = a.baz1; |
| 57 (/*warning:DynamicInvoke*/b1("hello")); | 57 (/*info:DynamicInvoke*/b1("hello")); |
| 58 A.baz2("hello"); | 58 A.baz2("hello"); |
| 59 var b2 = A.baz2; | 59 var b2 = A.baz2; |
| 60 (/*warning:DynamicInvoke*/b2("hello")); | 60 (/*info:DynamicInvoke*/b2("hello")); |
| 61 ''' | 61 ''' |
| 62 }); | 62 }); |
| 63 }); | 63 }); |
| 64 | 64 |
| 65 test('Primitives', () { | 65 test('Primitives', () { |
| 66 testChecker({ | 66 testChecker({ |
| 67 '/main.dart': ''' | 67 '/main.dart': ''' |
| 68 int /*severe:InvalidVariableDeclaration*/a; | 68 int /*severe:InvalidVariableDeclaration*/a; |
| 69 double /*severe:InvalidVariableDeclaration*/b; | 69 double /*severe:InvalidVariableDeclaration*/b; |
| 70 num c; | 70 num c; |
| (...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 a = a % b; | 1845 a = a % b; |
| 1846 a = a + b; | 1846 a = a + b; |
| 1847 a = a + /*pass should be severe:StaticTypeError*/a; | 1847 a = a + /*pass should be severe:StaticTypeError*/a; |
| 1848 a = a - b; | 1848 a = a - b; |
| 1849 b = /*severe:StaticTypeError*/b - b; | 1849 b = /*severe:StaticTypeError*/b - b; |
| 1850 a = a << b; | 1850 a = a << b; |
| 1851 a = a >> b; | 1851 a = a >> b; |
| 1852 a = a & b; | 1852 a = a & b; |
| 1853 a = a ^ b; | 1853 a = a ^ b; |
| 1854 a = a | b; | 1854 a = a | b; |
| 1855 c = (/*pass should be warning:DynamicInvoke*/c + b); | 1855 c = (/*pass should be info:DynamicInvoke*/c + b); |
| 1856 } | 1856 } |
| 1857 ''' | 1857 ''' |
| 1858 }); | 1858 }); |
| 1859 }); | 1859 }); |
| 1860 | 1860 |
| 1861 test('compound assignments', () { | 1861 test('compound assignments', () { |
| 1862 testChecker({ | 1862 testChecker({ |
| 1863 '/main.dart': ''' | 1863 '/main.dart': ''' |
| 1864 class A { | 1864 class A { |
| 1865 A operator *(B b) {} | 1865 A operator *(B b) {} |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 a %= b; | 1915 a %= b; |
| 1916 a += b; | 1916 a += b; |
| 1917 a += /*severe:StaticTypeError*/a; | 1917 a += /*severe:StaticTypeError*/a; |
| 1918 a -= b; | 1918 a -= b; |
| 1919 (/*severe:StaticTypeError*/b -= b); | 1919 (/*severe:StaticTypeError*/b -= b); |
| 1920 a <<= b; | 1920 a <<= b; |
| 1921 a >>= b; | 1921 a >>= b; |
| 1922 a &= b; | 1922 a &= b; |
| 1923 a ^= b; | 1923 a ^= b; |
| 1924 a |= b; | 1924 a |= b; |
| 1925 (/*warning:DynamicInvoke*/c += b); | 1925 (/*info:DynamicInvoke*/c += b); |
| 1926 } | 1926 } |
| 1927 ''' | 1927 ''' |
| 1928 }); | 1928 }); |
| 1929 }); | 1929 }); |
| 1930 | 1930 |
| 1931 test('super call placement', () { | 1931 test('super call placement', () { |
| 1932 testChecker({ | 1932 testChecker({ |
| 1933 '/main.dart': ''' | 1933 '/main.dart': ''' |
| 1934 class Base { | 1934 class Base { |
| 1935 var x; | 1935 var x; |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 f = bar as II2D; | 2799 f = bar as II2D; |
| 2800 f = bar as DD2I; | 2800 f = bar as DD2I; |
| 2801 f = bar as DI2D; | 2801 f = bar as DI2D; |
| 2802 f = bar as ID2D; | 2802 f = bar as ID2D; |
| 2803 f = bar as DD2D; | 2803 f = bar as DD2D; |
| 2804 } | 2804 } |
| 2805 ''' | 2805 ''' |
| 2806 }); | 2806 }); |
| 2807 }); | 2807 }); |
| 2808 } | 2808 } |
| OLD | NEW |