Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: tests/compiler/dart2js/link_test.dart

Issue 177963002: Use List instead of Link in the type system. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/compiler/dart2js/link_helper.dart ('k') | tests/compiler/dart2js/lookup_member_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/implementation/util/util.dart'; 6 import 'package:compiler/implementation/util/util.dart';
7 import 'package:compiler/implementation/util/util_implementation.dart'; 7 import 'package:compiler/implementation/util/util_implementation.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 } 24 }
25 25
26 testFromList(List list) {
27 test(new Link.fromList(list), list);
28 }
29
30 test(Link link, List list) { 26 test(Link link, List list) {
31 Expect.equals(list.isEmpty, link.isEmpty); 27 Expect.equals(list.isEmpty, link.isEmpty);
32 int i = 0; 28 int i = 0;
33 for (var element in link.toList()) { 29 for (var element in link.toList()) {
34 Expect.equals(list[i++], element); 30 Expect.equals(list[i++], element);
35 } 31 }
36 Expect.equals(list.length, i); 32 Expect.equals(list.length, i);
37 i = 0; 33 i = 0;
38 for (var element in link) { 34 for (var element in link) {
39 Expect.equals(list[i++], element); 35 Expect.equals(list[i++], element);
40 } 36 }
41 Expect.equals(list.length, i); 37 Expect.equals(list.length, i);
42 i = 0; 38 i = 0;
43 for (; !link.isEmpty; link = link.tail) { 39 for (; !link.isEmpty; link = link.tail) {
44 Expect.equals(list[i++], link.head); 40 Expect.equals(list[i++], link.head);
45 } 41 }
46 Expect.equals(list.length, i); 42 Expect.equals(list.length, i);
47 Expect.isTrue(link.isEmpty); 43 Expect.isTrue(link.isEmpty);
48 } 44 }
49 45
50 testSkip() { 46 testSkip() {
51 var nonEmptyLink = new Link.fromList([0, 1, 2, 3, 4, 5]); 47 var nonEmptyLink = LinkFromList([0, 1, 2, 3, 4, 5]);
52 for (int i = 0 ; i < 5; i++) { 48 for (int i = 0 ; i < 5; i++) {
53 var link = nonEmptyLink.skip(i); 49 var link = nonEmptyLink.skip(i);
54 Expect.isFalse(link.isEmpty); 50 Expect.isFalse(link.isEmpty);
55 Expect.equals(i, link.head); 51 Expect.equals(i, link.head);
56 } 52 }
57 Expect.isTrue(nonEmptyLink.skip(6).isEmpty); 53 Expect.isTrue(nonEmptyLink.skip(6).isEmpty);
58 Expect.throws(() => nonEmptyLink.skip(7), (e) => e is RangeError); 54 Expect.throws(() => nonEmptyLink.skip(7), (e) => e is RangeError);
59 55
60 var emptyLink = const Link(); 56 var emptyLink = const Link();
61 Expect.isTrue(emptyLink.skip(0).isEmpty); 57 Expect.isTrue(emptyLink.skip(0).isEmpty);
62 Expect.throws(() => emptyLink.skip(1), (e) => e is RangeError); 58 Expect.throws(() => emptyLink.skip(1), (e) => e is RangeError);
63 } 59 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/link_helper.dart ('k') | tests/compiler/dart2js/lookup_member_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698