OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 testing factories. | 4 // Dart test program for testing factories. |
5 | 5 |
6 interface Link<T> extends Iterable<T> factory LinkFactory<T> { | 6 interface Link<T> extends Iterable<T> factory LinkFactory<T> { |
7 Link(T head, [Link<T> tail]); | 7 Link(T head, [Link<T> tail]); |
8 Link<T> prepend(T element); | 8 Link<T> prepend(T element); |
9 } | 9 } |
10 | 10 |
11 interface EmptyLink<T> extends Link<T> factory LinkTail<T> { | 11 interface EmptyLink<T> extends Link<T> default LinkTail<T> { |
12 const EmptyLink(); | 12 const EmptyLink(); |
13 } | 13 } |
14 | 14 |
15 class LinkFactory<T> { | 15 class LinkFactory<T> { |
16 factory Link(head, [Link tail]) { | 16 factory Link(head, [Link tail]) { |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 class AbstractLink<T> implements Link<T> { | 20 class AbstractLink<T> implements Link<T> { |
21 const AbstractLink(); | 21 const AbstractLink(); |
(...skipping 13 matching lines...) Expand all Loading... |
35 class Fisk { | 35 class Fisk { |
36 Link<String> nodes = const EmptyLink(); | 36 Link<String> nodes = const EmptyLink(); |
37 } | 37 } |
38 | 38 |
39 main() { | 39 main() { |
40 new Fisk(); | 40 new Fisk(); |
41 new EmptyLink<String>().prepend('hest'); | 41 new EmptyLink<String>().prepend('hest'); |
42 const EmptyLink<String>().prepend('fisk'); | 42 const EmptyLink<String>().prepend('fisk'); |
43 } | 43 } |
44 | 44 |
OLD | NEW |