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

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

Issue 11778039: Report arity errors on user definable operators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + Link test updated. Created 7 years, 11 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/co19/co19-dart2js.status ('k') | no next file » | 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 '../../../sdk/lib/_internal/compiler/implementation/util/util.dart'; 5 import '../../../sdk/lib/_internal/compiler/implementation/util/util.dart';
6 import '../../../sdk/lib/_internal/compiler/implementation/util/util_implementat ion.dart'; 6 import '../../../sdk/lib/_internal/compiler/implementation/util/util_implementat ion.dart';
7 7
8 main() { 8 main() {
9 test(const Link<Comparable>().prepend('three').prepend(2).prepend('one'), 9 test(const Link<Comparable>().prepend('three').prepend(2).prepend('one'),
10 ['one', 2, 'three']); 10 ['one', 2, 'three']);
11 test(const Link<Comparable>().prepend(3).prepend('two').prepend(1), 11 test(const Link<Comparable>().prepend(3).prepend('two').prepend(1),
12 [1, 'two', 3]); 12 [1, 'two', 3]);
13 test(const Link<String>().prepend('single'), ['single']); 13 test(const Link<String>().prepend('single'), ['single']);
14 test(const Link(), []); 14 test(const Link(), []);
15 testFromList([]); 15 testFromList([]);
16 testFromList([0]); 16 testFromList([0]);
17 testFromList([0, 1]); 17 testFromList([0, 1]);
18 testFromList([0, 1, 2]); 18 testFromList([0, 1, 2]);
19 testFromList([0, 1, 2, 3]); 19 testFromList([0, 1, 2, 3]);
20 testFromList([0, 1, 2, 3, 4]); 20 testFromList([0, 1, 2, 3, 4]);
21 testFromList([0, 1, 2, 3, 4, 5]); 21 testFromList([0, 1, 2, 3, 4, 5]);
22 testSkip();
22 } 23 }
23 24
24 testFromList(List list) { 25 testFromList(List list) {
25 test(new Link.fromList(list), list); 26 test(new Link.fromList(list), list);
26 } 27 }
27 28
28 test(Link link, List list) { 29 test(Link link, List list) {
29 Expect.equals(list.isEmpty, link.isEmpty); 30 Expect.equals(list.isEmpty, link.isEmpty);
30 int i = 0; 31 int i = 0;
31 for (var element in link.toList()) { 32 for (var element in link.toList()) {
32 Expect.equals(list[i++], element); 33 Expect.equals(list[i++], element);
33 } 34 }
34 Expect.equals(list.length, i); 35 Expect.equals(list.length, i);
35 i = 0; 36 i = 0;
36 for (var element in link) { 37 for (var element in link) {
37 Expect.equals(list[i++], element); 38 Expect.equals(list[i++], element);
38 } 39 }
39 Expect.equals(list.length, i); 40 Expect.equals(list.length, i);
40 i = 0; 41 i = 0;
41 for (; !link.isEmpty; link = link.tail) { 42 for (; !link.isEmpty; link = link.tail) {
42 Expect.equals(list[i++], link.head); 43 Expect.equals(list[i++], link.head);
43 } 44 }
44 Expect.equals(list.length, i); 45 Expect.equals(list.length, i);
45 Expect.isTrue(link.isEmpty); 46 Expect.isTrue(link.isEmpty);
46 } 47 }
48
49 testSkip() {
50 var nonEmptyLink = new Link.fromList([0, 1, 2, 3, 4, 5]);
51 for (int i = 0 ; i < 5; i++) {
52 var link = nonEmptyLink.skip(i);
53 Expect.isFalse(link.isEmpty);
54 Expect.equals(i, link.head);
55 }
56 Expect.isTrue(nonEmptyLink.skip(6).isEmpty);
57 Expect.throws(() => nonEmptyLink.skip(7), (e) => e is RangeError);
58
59 var emptyLink = const Link();
60 Expect.isTrue(emptyLink.skip(0).isEmpty);
61 Expect.throws(() => emptyLink.skip(1), (e) => e is RangeError);
62 }
OLDNEW
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698