OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Checks that noSuchMethod is resolved in the super class and not in the | 7 // Checks that noSuchMethod is resolved in the super class and not in the |
8 // current class. | 8 // current class. |
9 | 9 |
10 class C { | 10 class C { |
11 E e = new E(); | 11 E e = new E(); |
12 | 12 |
13 bool noSuchMethod(Invocation im) { | 13 bool noSuchMethod(Invocation im) { |
14 if (im.memberName == 'foo') { | 14 if (im.memberName == const Symbol('foo')) { |
15 return im.positionalArguments.isEmpty && | 15 return im.positionalArguments.isEmpty && |
16 im.namedArguments.isEmpty && | 16 im.namedArguments.isEmpty && |
17 im.invokeOn(e); | 17 im.invokeOn(e); |
18 } | 18 } |
19 if (im.memberName == 'bar') { | 19 if (im.memberName == const Symbol('bar')) { |
20 return im.positionalArguments.length == 1 && | 20 return im.positionalArguments.length == 1 && |
21 im.namedArguments.isEmpty && | 21 im.namedArguments.isEmpty && |
22 im.invokeOn(e); | 22 im.invokeOn(e); |
23 } | 23 } |
24 if (im.memberName == 'baz') { | 24 if (im.memberName == const Symbol('baz')) { |
25 return im.positionalArguments.isEmpty && | 25 return im.positionalArguments.isEmpty && |
26 im.namedArguments.length == 1 && | 26 im.namedArguments.length == 1 && |
27 im.invokeOn(e); | 27 im.invokeOn(e); |
28 } | 28 } |
29 if (im.memberName == 'boz') { | 29 if (im.memberName == const Symbol('boz')) { |
30 return im.positionalArguments.length == 1 && | 30 return im.positionalArguments.length == 1 && |
31 im.namedArguments.length == 1 && | 31 im.namedArguments.length == 1 && |
32 im.invokeOn(e); | 32 im.invokeOn(e); |
33 } | 33 } |
34 return false; | 34 return false; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 class D extends C { | 38 class D extends C { |
39 bool noSuchMethod(Invocation im) { | 39 bool noSuchMethod(Invocation im) { |
(...skipping 20 matching lines...) Expand all Loading... |
60 bool boz(int a, {int c}) => a == 1 && c == 2; | 60 bool boz(int a, {int c}) => a == 1 && c == 2; |
61 } | 61 } |
62 | 62 |
63 main() { | 63 main() { |
64 var d = new D(); | 64 var d = new D(); |
65 Expect.isTrue(d.test1()); | 65 Expect.isTrue(d.test1()); |
66 Expect.isTrue(d.test2()); | 66 Expect.isTrue(d.test2()); |
67 Expect.isTrue(d.test3()); | 67 Expect.isTrue(d.test3()); |
68 Expect.isTrue(d.test4()); | 68 Expect.isTrue(d.test4()); |
69 } | 69 } |
OLD | NEW |