| 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 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'package:compiler/src/util/util.dart'; | 6 import 'package:compiler/src/util/util.dart'; |
| 7 import 'link_helper.dart'; | 7 import 'link_helper.dart'; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 test(const Link<Comparable>().prepend('three').prepend(2).prepend('one'), | 10 test(const Link<Comparable>().prepend('three').prepend(2).prepend('one'), |
| 11 ['one', 2, 'three']); | 11 ['one', 2, 'three']); |
| 12 test(const Link<Comparable>().prepend(3).prepend('two').prepend(1), | 12 test(const Link<Comparable>().prepend(3).prepend('two').prepend(1), |
| 13 [1, 'two', 3]); | 13 [1, 'two', 3]); |
| 14 test(const Link<String>().prepend('single'), ['single']); | 14 test(const Link<String>().prepend('single'), ['single']); |
| 15 test(const Link(), []); | 15 test(const Link(), []); |
| 16 testFromList([]); | 16 testFromList([]); |
| 17 testFromList([0]); | 17 testFromList([0]); |
| 18 testFromList([0, 1]); | 18 testFromList([0, 1]); |
| 19 testFromList([0, 1, 2]); | 19 testFromList([0, 1, 2]); |
| 20 testFromList([0, 1, 2, 3]); | 20 testFromList([0, 1, 2, 3]); |
| 21 testFromList([0, 1, 2, 3, 4]); | 21 testFromList([0, 1, 2, 3, 4]); |
| 22 testFromList([0, 1, 2, 3, 4, 5]); | 22 testFromList([0, 1, 2, 3, 4, 5]); |
| 23 testSkip(); | 23 testSkip(); |
| 24 |
| 25 testCopyWithout(); |
| 24 } | 26 } |
| 25 | 27 |
| 26 testFromList(List list) { | 28 testFromList(List list) { |
| 27 test(LinkFromList(list), list); | 29 test(LinkFromList(list), list); |
| 28 } | 30 } |
| 29 | 31 |
| 30 test(Link link, List list) { | 32 test(Link link, List list) { |
| 31 Expect.equals(list.isEmpty, link.isEmpty); | 33 Expect.equals(list.isEmpty, link.isEmpty); |
| 32 int i = 0; | 34 int i = 0; |
| 33 for (var element in link.toList()) { | 35 for (var element in link.toList()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 Expect.isFalse(link.isEmpty); | 56 Expect.isFalse(link.isEmpty); |
| 55 Expect.equals(i, link.head); | 57 Expect.equals(i, link.head); |
| 56 } | 58 } |
| 57 Expect.isTrue(nonEmptyLink.skip(6).isEmpty); | 59 Expect.isTrue(nonEmptyLink.skip(6).isEmpty); |
| 58 Expect.throws(() => nonEmptyLink.skip(7), (e) => e is RangeError); | 60 Expect.throws(() => nonEmptyLink.skip(7), (e) => e is RangeError); |
| 59 | 61 |
| 60 var emptyLink = const Link(); | 62 var emptyLink = const Link(); |
| 61 Expect.isTrue(emptyLink.skip(0).isEmpty); | 63 Expect.isTrue(emptyLink.skip(0).isEmpty); |
| 62 Expect.throws(() => emptyLink.skip(1), (e) => e is RangeError); | 64 Expect.throws(() => emptyLink.skip(1), (e) => e is RangeError); |
| 63 } | 65 } |
| 66 |
| 67 testCopyWithout() { |
| 68 test(const Link().copyWithout(0), []); |
| 69 |
| 70 test(LinkFromList([0]).copyWithout(0), []); |
| 71 test(LinkFromList([0, 1]).copyWithout(0), [1]); |
| 72 test(LinkFromList([0, 1, 2]).copyWithout(0), [1, 2]); |
| 73 test(LinkFromList([0, 1, 2]).copyWithout(1), [0, 2]); |
| 74 test(LinkFromList([0, 1, 2]).copyWithout(2), [0, 1]); |
| 75 test(LinkFromList([0, 1, 2]).copyWithout(3), [0, 1, 2]); |
| 76 } |
| OLD | NEW |