OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, 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 | |
6 // Test that a factory provider can provide for more than one interface. | |
7 | |
8 interface A default F { | |
9 A(var secret); | |
10 | |
11 GetSecret(); | |
12 } | |
13 | |
14 class AImpl implements A { | |
15 String _secret; | |
16 | |
17 AImpl(String one, String two) : _secret = "${one}${two}"; | |
18 | |
19 String GetSecret() { return _secret; } | |
20 } | |
21 | |
22 interface B default F { | |
23 B(var secret); | |
24 | |
25 GetSecret(); | |
26 } | |
27 | |
28 class BImpl implements B { | |
29 String _secret; | |
30 | |
31 BImpl(String one, String two) : _secret = "${two}${one}"; | |
32 | |
33 String GetSecret() { return _secret; } | |
34 } | |
35 | |
36 | |
37 // One factory provider for two interfaces. | |
38 class F { | |
39 factory A(var secret) { | |
40 return new AImpl(secret, 'A'); | |
41 } | |
42 | |
43 factory B(var secret) { | |
44 return new BImpl(secret, 'B'); | |
45 } | |
46 } | |
47 | |
48 main() { | |
49 Expect.equals('1A', new A('1').GetSecret()); | |
50 Expect.equals('B2', new B('2').GetSecret()); | |
51 } | |
OLD | NEW |