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

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

Issue 959003003: Typecheck constructor initializers properly (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 9 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/info.dart ('k') | test/codegen/expect/_internal/_internal.js » ('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 ddc.test.checker_test; 6 library ddc.test.checker_test;
7 7
8 import 'package:unittest/compact_vm_config.dart'; 8 import 'package:unittest/compact_vm_config.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // check at construction. 123 // check at construction.
124 T x; 124 T x;
125 125
126 // TODO(vsm): Should this be a different type of DownCast? 126 // TODO(vsm): Should this be a different type of DownCast?
127 T foo() => /*warning:DownCastLiteral*/null; 127 T foo() => /*warning:DownCastLiteral*/null;
128 } 128 }
129 ''' 129 '''
130 }); 130 });
131 }); 131 });
132 132
133 test('Constructors', () {
134 testChecker({
135 '/main.dart': '''
136 const num z = 25;
137 Object obj = "world";
138
139 class A {
140 int x;
141 String y;
142
143 A(this.x) : this.y = /*severe:StaticTypeError*/42;
144
145 A.c1(p): this.x = /*info:DownCast*/z, this.y = /*info:DownCast*/p;
146
147 A.c2(this.x, this.y);
148
149 A.c3(/*severe:InvalidParameterDeclaration*/num this.x, String this.y);
150 }
151
152 class B extends A {
153 B() : super(/*severe:StaticTypeError*/"hello");
154
155 B.c2(int x, String y) : super.c2(/*severe:StaticTypeError*/y,
156 /*severe:StaticTypeError*/x);
157
158 B.c3(num x, Object y) : super.c3(x, /*info:DownCast*/y);
159 }
160
161 void main() {
162 A a = new A.c2(/*info:DownCast*/z, /*severe:StaticTypeError*/z);
163 var b = new B.c2(/*severe:StaticTypeError*/"hello", /*info:DownCast*/ob j);
164 }
165 '''
166 });
167 });
168
133 test('Unbound variable', () { 169 test('Unbound variable', () {
134 testChecker({ 170 testChecker({
135 '/main.dart': ''' 171 '/main.dart': '''
136 void main() { 172 void main() {
137 dynamic y = /*pass should be severe:StaticTypeError*/unboundVariable; 173 dynamic y = /*pass should be severe:StaticTypeError*/unboundVariable;
138 } 174 }
139 ''' 175 '''
140 }); 176 });
141 }); 177 });
142 178
(...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 '/main.dart': ''' 2639 '/main.dart': '''
2604 class A {} 2640 class A {}
2605 class T1 implements A { 2641 class T1 implements A {
2606 /*severe:InferableOverride*/toString() {} 2642 /*severe:InferableOverride*/toString() {}
2607 } 2643 }
2608 ''' 2644 '''
2609 }, inferFromOverrides: false); 2645 }, inferFromOverrides: false);
2610 }); 2646 });
2611 }); 2647 });
2612 } 2648 }
OLDNEW
« no previous file with comments | « lib/src/info.dart ('k') | test/codegen/expect/_internal/_internal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698