OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Dart test program for constructors and initializers. |
4 | 5 |
5 // Test that implicit setters in checked mode do a type check. | 6 // Check function subtyping of static functions. |
6 | 7 |
7 import "package:expect/expect.dart"; | 8 import 'package:expect/expect.dart'; |
8 | 9 |
9 class A { | 10 typedef I<T> f2<T>(); |
10 C c; | 11 |
| 12 class X { |
| 13 static J<bool> f1() => null; |
11 } | 14 } |
12 | 15 |
13 class B extends A { | 16 class C<T> { |
| 17 C(f2<T> f); |
14 } | 18 } |
15 | 19 |
16 class C { | 20 class I<T> {} |
17 } | 21 class J<T> extends I<int> {} |
18 | |
19 var array = [new B()]; | |
20 | 22 |
21 main() { | 23 main() { |
22 array[0].c = new C(); | 24 |
23 bool inCheckedMode = false; | 25 bool inCheckedMode = false; |
24 try { | 26 try { |
25 String a = 42; | 27 String a = 42; |
26 } catch (e) { | 28 } catch (e) { |
27 inCheckedMode = true; | 29 inCheckedMode = true; |
28 } | 30 } |
| 31 |
| 32 new C<int>(X.f1); |
29 if (inCheckedMode) { | 33 if (inCheckedMode) { |
30 Expect.throws(() => array[0].c = new B(), (e) => e is TypeError); | 34 Expect.throws(() => new C<bool>(X.f1), (e) => true); |
31 } | 35 } |
32 } | 36 } |
OLD | NEW |