Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/checker/checker_test.dart

Issue 1160673003: fixes #202, check IndexExpression (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/src/checker/checker.dart ('k') | test/dart_codegen/expect/_internal/list.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:test/test.dart'; 8 import 'package:test/test.dart';
9 9
10 import 'package:dev_compiler/src/testing.dart'; 10 import 'package:dev_compiler/src/testing.dart';
(...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 /*severe:InvalidMethodOverride*/C m2(C value) {} 1916 /*severe:InvalidMethodOverride*/C m2(C value) {}
1917 /*severe:InvalidMethodOverride*/A m3(C value) {} 1917 /*severe:InvalidMethodOverride*/A m3(C value) {}
1918 C m4(A value) {} 1918 C m4(A value) {}
1919 /*severe:InvalidMethodOverride*/m5(value) {} 1919 /*severe:InvalidMethodOverride*/m5(value) {}
1920 /*severe:InvalidMethodOverride*/dynamic m6(dynamic value) {} 1920 /*severe:InvalidMethodOverride*/dynamic m6(dynamic value) {}
1921 } 1921 }
1922 ''' 1922 '''
1923 }, inferFromOverrides: true); 1923 }, inferFromOverrides: true);
1924 }); 1924 });
1925 1925
1926 test('binary operators', () { 1926 test('binary and index operators', () {
1927 testChecker({ 1927 testChecker({
1928 '/main.dart': ''' 1928 '/main.dart': '''
1929 class A { 1929 class A {
1930 A operator *(B b) {} 1930 A operator *(B b) {}
1931 A operator /(B b) {} 1931 A operator /(B b) {}
1932 A operator ~/(B b) {} 1932 A operator ~/(B b) {}
1933 A operator %(B b) {} 1933 A operator %(B b) {}
1934 A operator +(B b) {} 1934 A operator +(B b) {}
1935 A operator -(B b) {} 1935 A operator -(B b) {}
1936 A operator <<(B b) {} 1936 A operator <<(B b) {}
1937 A operator >>(B b) {} 1937 A operator >>(B b) {}
1938 A operator &(B b) {} 1938 A operator &(B b) {}
1939 A operator ^(B b) {} 1939 A operator ^(B b) {}
1940 A operator |(B b) {} 1940 A operator |(B b) {}
1941 A operator[](B b) {}
1941 } 1942 }
1942 1943
1943 class B { 1944 class B {
1944 A operator -(B b) {} 1945 A operator -(B b) {}
1945 } 1946 }
1946 1947
1947 foo() => new A(); 1948 foo() => new A();
1948 1949
1949 test() { 1950 test() {
1950 A a = new A(); 1951 A a = new A();
(...skipping 21 matching lines...) Expand all
1972 x = x + /*info:DynamicCast*/c; 1973 x = x + /*info:DynamicCast*/c;
1973 x = x + /*severe:StaticTypeError*/y; 1974 x = x + /*severe:StaticTypeError*/y;
1974 1975
1975 bool p = true; 1976 bool p = true;
1976 p = p && p; 1977 p = p && p;
1977 p = p && /*info:DynamicCast*/c; 1978 p = p && /*info:DynamicCast*/c;
1978 p = (/*info:DynamicCast*/c) && p; 1979 p = (/*info:DynamicCast*/c) && p;
1979 p = (/*info:DynamicCast*/c) && /*info:DynamicCast*/c; 1980 p = (/*info:DynamicCast*/c) && /*info:DynamicCast*/c;
1980 p = (/*severe:StaticTypeError*/y) && p; 1981 p = (/*severe:StaticTypeError*/y) && p;
1981 p = c == y; 1982 p = c == y;
1983
1984 a = a[b];
1985 a = a[/*info:DynamicCast*/c];
1986 c = (/*info:DynamicInvoke*/c[b]);
1987 a[/*severe:StaticTypeError*/y];
1982 } 1988 }
1983 ''' 1989 '''
1984 }); 1990 });
1985 }); 1991 });
1986 1992
1987 test('compound assignments', () { 1993 test('compound assignments', () {
1988 testChecker({ 1994 testChecker({
1989 '/main.dart': ''' 1995 '/main.dart': '''
1990 class A { 1996 class A {
1991 A operator *(B b) {} 1997 A operator *(B b) {}
1992 A operator /(B b) {} 1998 A operator /(B b) {}
1993 A operator ~/(B b) {} 1999 A operator ~/(B b) {}
1994 A operator %(B b) {} 2000 A operator %(B b) {}
1995 A operator +(B b) {} 2001 A operator +(B b) {}
1996 A operator -(B b) {} 2002 A operator -(B b) {}
1997 A operator <<(B b) {} 2003 A operator <<(B b) {}
1998 A operator >>(B b) {} 2004 A operator >>(B b) {}
1999 A operator &(B b) {} 2005 A operator &(B b) {}
2000 A operator ^(B b) {} 2006 A operator ^(B b) {}
2001 A operator |(B b) {} 2007 A operator |(B b) {}
2008 D operator [](B index) {}
2009 void operator []=(B index, D value) {}
2002 } 2010 }
2003 2011
2004 class B { 2012 class B {
2005 A operator -(B b) {} 2013 A operator -(B b) {}
2006 } 2014 }
2007 2015
2016 class D {
2017 D operator +(D d) {}
2018 }
2019
2008 foo() => new A(); 2020 foo() => new A();
2009 2021
2010 test() { 2022 test() {
2011 int x = 0; 2023 int x = 0;
2012 x += 5; 2024 x += 5;
2013 (/*severe:StaticTypeError*/x += 3.14); 2025 (/*severe:StaticTypeError*/x += 3.14);
2014 2026
2015 double y = 0.0; 2027 double y = 0.0;
2016 y += 5; 2028 y += 5;
2017 y += 3.14; 2029 y += 3.14;
(...skipping 24 matching lines...) Expand all
2042 a += b; 2054 a += b;
2043 a += /*severe:StaticTypeError*/a; 2055 a += /*severe:StaticTypeError*/a;
2044 a -= b; 2056 a -= b;
2045 (/*severe:StaticTypeError*/b -= b); 2057 (/*severe:StaticTypeError*/b -= b);
2046 a <<= b; 2058 a <<= b;
2047 a >>= b; 2059 a >>= b;
2048 a &= b; 2060 a &= b;
2049 a ^= b; 2061 a ^= b;
2050 a |= b; 2062 a |= b;
2051 (/*info:DynamicInvoke*/c += b); 2063 (/*info:DynamicInvoke*/c += b);
2064
2065 var d = new D();
2066 a[b] += d;
2067 a[/*info:DynamicCast*/c] += d;
2068 a[/*severe:StaticTypeError*/z] += d;
2069 a[b] += /*info:DynamicCast*/c;
2070 a[b] += /*severe:StaticTypeError*/z;
2071 (/*info:DynamicInvoke*/(/*info:DynamicInvoke*/c[b]) += d);
2052 } 2072 }
2053 ''' 2073 '''
2054 }); 2074 });
2055 }); 2075 });
2056 2076
2057 test('super call placement', () { 2077 test('super call placement', () {
2058 testChecker({ 2078 testChecker({
2059 '/main.dart': ''' 2079 '/main.dart': '''
2060 class Base { 2080 class Base {
2061 var x; 2081 var x;
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2925 f = bar as II2D; 2945 f = bar as II2D;
2926 f = bar as DD2I; 2946 f = bar as DD2I;
2927 f = bar as DI2D; 2947 f = bar as DI2D;
2928 f = bar as ID2D; 2948 f = bar as ID2D;
2929 f = bar as DD2D; 2949 f = bar as DD2D;
2930 } 2950 }
2931 ''' 2951 '''
2932 }); 2952 });
2933 }); 2953 });
2934 } 2954 }
OLDNEW
« no previous file with comments | « lib/src/checker/checker.dart ('k') | test/dart_codegen/expect/_internal/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698