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 | 4 |
5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 | 6 |
7 class A { | 7 class A { |
8 foo(required1, { named1: 499}) => -(required1 + named1 * 3); | 8 foo(required1, {named1: 499}) => -(required1 + named1 * 3); |
9 bar(required1, required2, { named1: 13, named2: 17}) | 9 bar(required1, required2, {named1: 13, named2: 17}) => |
10 => -(required1 + required2 * 3 + named1 * 5 + named2 * 7); | 10 -(required1 + required2 * 3 + named1 * 5 + named2 * 7); |
11 gee({named1: 31}) => -named1; | 11 gee({named1: 31}) => -named1; |
12 } | 12 } |
13 | 13 |
14 class B extends A { | 14 class B extends A { |
15 foo(required1) => required1; | 15 foo(required1) => required1; |
16 bar(required1, required2, { named1: 29 }) | 16 bar(required1, required2, {named1: 29}) => |
17 => required1 + required2 * 3 + named1 * 5; | 17 required1 + required2 * 3 + named1 * 5; |
18 gee({named2: 11}) => named2 * 99; | 18 gee({named2: 11}) => named2 * 99; |
19 } | 19 } |
20 | 20 |
21 main() { | 21 main() { |
22 // Invoke all A methods so that they are registered. | 22 // Invoke all A methods so that they are registered. |
23 var a = new A(); | 23 var a = new A(); |
24 Expect.equals(-2092, | 24 Expect.equals( |
25 a.foo(499, named1: 88) + a.bar(1, 2, named1: 3, named2: 88) + | 25 -2092, |
26 a.bar(1, 2, named2: 88) + a.gee(named1: 3)); | 26 a.foo(499, named1: 88) + |
| 27 a.bar(1, 2, named1: 3, named2: 88) + |
| 28 a.bar(1, 2, named2: 88) + |
| 29 a.gee(named1: 3)); |
27 var b = new B(); | 30 var b = new B(); |
28 Expect.throws(() => b.foo(499, named1: 88), (e) => e is NoSuchMethodError); | 31 Expect.throws(() => b.foo(499, named1: 88), (e) => e is NoSuchMethodError); |
29 Expect.throws(() => b.bar(1, 2, named1: 3, named2: 88), | 32 Expect.throws( |
30 (e) => e is NoSuchMethodError); | 33 () => b.bar(1, 2, named1: 3, named2: 88), (e) => e is NoSuchMethodError); |
31 Expect.throws(() => b.bar(1, 2, named2: 88), | 34 Expect.throws(() => b.bar(1, 2, named2: 88), (e) => e is NoSuchMethodError); |
32 (e) => e is NoSuchMethodError); | 35 Expect.throws(() => b.gee(named1: 3), (e) => e is NoSuchMethodError); |
33 Expect.throws(() => b.gee(named1: 3), | 36 } |
34 (e) => e is NoSuchMethodError); | |
35 } | |
OLD | NEW |