OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import "package:expect/expect.dart"; | |
6 | |
7 // When attempting to call a nonexistent static method, getter or setter, check | |
8 // that a NoSuchMethodError is thrown. | |
9 | |
10 class C {} | |
11 | |
12 class D { | |
13 get hest => 1; // //# 04: continued | |
14 set hest(val) {} // //# 05: continued | |
15 } | |
16 | |
17 get fisk => 2; //# 09: continued | |
18 set fisk(val) {} //# 10: continued | |
19 | |
20 expectNsme([void fun()]) { | |
21 if (fun != null) { | |
22 Expect.throws(fun, (e) => e is NoSuchMethodError); | |
23 } | |
24 } | |
25 | |
26 alwaysThrows() { | |
27 throw new NoSuchMethodError(null, const Symbol('foo'), [], {}); | |
28 } | |
29 | |
30 test01() { | |
31 C.hest = 1; // //# 01: static type warning | |
32 } | |
33 | |
34 test02() { | |
35 C.hest; // //# 02: static type warning | |
36 } | |
37 | |
38 test03() { | |
39 C.hest(); // //# 03: static type warning | |
40 } | |
41 | |
42 test04() { | |
43 D.hest = 1; // //# 04: static type warning | |
44 } | |
45 | |
46 test05() { | |
47 D.hest; // //# 05: static type warning | |
48 } | |
49 | |
50 test06() { | |
51 fisk = 1; // //# 06: static type warning | |
52 } | |
53 | |
54 test07() { | |
55 fisk; // //# 07: static type warning | |
56 } | |
57 | |
58 test08() { | |
59 fisk(); // //# 08: static type warning | |
60 } | |
61 | |
62 test09() { | |
63 fisk = 1; // //# 09: static type warning | |
64 } | |
65 | |
66 test10() { | |
67 fisk; // //# 10: static type warning | |
68 } | |
69 | |
70 main() { | |
71 expectNsme(alwaysThrows); | |
72 expectNsme( | |
73 test01 // //# 01: continued | |
74 ); | |
75 expectNsme( | |
76 test02 // //# 02: continued | |
77 ); | |
78 expectNsme( | |
79 test03 // //# 03: continued | |
80 ); | |
81 expectNsme( | |
82 test04 // //# 04: continued | |
83 ); | |
84 expectNsme( | |
85 test05 // //# 05: continued | |
86 ); | |
87 expectNsme( | |
88 test06 // //# 06: continued | |
89 ); | |
90 expectNsme( | |
91 test07 // //# 07: continued | |
92 ); | |
93 expectNsme( | |
94 test08 // //# 08: continued | |
95 ); | |
96 expectNsme( | |
97 test09 // //# 09: continued | |
98 ); | |
99 expectNsme( | |
100 test10 // //# 10: continued | |
101 ); | |
102 } | |
OLD | NEW |