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

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: Created 5 years, 10 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
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
138 class A {
139 int x;
140 String y;
141
142 A(this.x) : this.y = /*severe:StaticTypeError*/42;
143
144 A.c1(p): this.x = /*info:DownCast*/z, this.y = /*info:DownCast*/p;
145
146 A.c2(this.x, this.y);
147 }
Leaf 2015/02/26 22:00:16 I think you can say something like: A.c3(num this
vsm 2015/02/26 23:55:47 Added - along with code to fix. :-)
148
149 class B extends A {
150 B() : super(/*severe:StaticTypeError*/"hello");
151
152 B.c2(int x, String y) : super.c2(/*severe:StaticTypeError*/y,
153 /*severe:StaticTypeError*/x);
154 }
155
156 void main() {
157 var a = new A.c2(z, z);
158 }
159 '''
160 });
161 });
162
133 test('Unbound variable', () { 163 test('Unbound variable', () {
134 testChecker({ 164 testChecker({
135 '/main.dart': ''' 165 '/main.dart': '''
136 void main() { 166 void main() {
137 dynamic y = /*pass should be severe:StaticTypeError*/unboundVariable; 167 dynamic y = /*pass should be severe:StaticTypeError*/unboundVariable;
138 } 168 }
139 ''' 169 '''
140 }); 170 });
141 }); 171 });
142 172
(...skipping 2460 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 '/main.dart': ''' 2633 '/main.dart': '''
2604 class A {} 2634 class A {}
2605 class T1 implements A { 2635 class T1 implements A {
2606 /*severe:InferableOverride*/toString() {} 2636 /*severe:InferableOverride*/toString() {}
2607 } 2637 }
2608 ''' 2638 '''
2609 }, inferFromOverrides: false); 2639 }, inferFromOverrides: false);
2610 }); 2640 });
2611 }); 2641 });
2612 } 2642 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698