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

Side by Side Diff: tests/html/node_test.dart

Issue 11412086: Make 'where' lazy. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: FilteredIterable/Iterator -> WhereIterable/Iterator. Created 8 years, 1 month 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
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 library NodeTest; 5 library NodeTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:svg'; 9 import 'dart:svg';
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 test('forEach', () { 73 test('forEach', () {
74 var nodes = []; 74 var nodes = [];
75 var node = makeNodeWithChildren(); 75 var node = makeNodeWithChildren();
76 node.nodes.forEach((n) => nodes.add(n)); 76 node.nodes.forEach((n) => nodes.add(n));
77 expect(nodes[0], isText); 77 expect(nodes[0], isText);
78 expect(nodes[1], isBRElement); 78 expect(nodes[1], isBRElement);
79 expect(nodes[2], isComment); 79 expect(nodes[2], isComment);
80 }); 80 });
81 81
82 test('filter', () { 82 test('where', () {
83 var filtered = makeNodeWithChildren().nodes.where((n) => n is BRElement); 83 var filtered =
84 makeNodeWithChildren().nodes.where((n) => n is BRElement).toList();
84 expect(filtered.length, 1); 85 expect(filtered.length, 1);
85 expect(filtered[0], isBRElement); 86 expect(filtered[0], isBRElement);
86 expect(filtered, isNodeList); 87 expect(filtered, isNodeList);
87 }); 88 });
88 89
89 test('every', () { 90 test('every', () {
90 var node = makeNodeWithChildren(); 91 var node = makeNodeWithChildren();
91 expect(node.nodes.every((n) => n is Node), isTrue); 92 expect(node.nodes.every((n) => n is Node), isTrue);
92 expect(node.nodes.every((n) => n is Comment), isFalse); 93 expect(node.nodes.every((n) => n is Comment), isFalse);
93 }); 94 });
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 }); 177 });
177 178
178 test('getRange', () { 179 test('getRange', () {
179 var node = makeNodeWithChildren(); 180 var node = makeNodeWithChildren();
180 expect(node.nodes.getRange(1, 2), isNodeList); 181 expect(node.nodes.getRange(1, 2), isNodeList);
181 }); 182 });
182 }); 183 });
183 184
184 group('_NodeList', () { 185 group('_NodeList', () {
185 List<Node> makeNodeList() => 186 List<Node> makeNodeList() =>
186 makeNodeWithChildren().nodes.where((_) => true); 187 makeNodeWithChildren().nodes.where((_) => true).toList();
187 188
188 test('first', () { 189 test('first', () {
189 var nodes = makeNodeList(); 190 var nodes = makeNodeList();
190 expect(nodes.first, isText); 191 expect(nodes.first, isText);
191 }); 192 });
192 193
193 test('filter', () { 194 test('where', () {
194 var filtered = makeNodeList().where((n) => n is BRElement); 195 var filtered = makeNodeList().where((n) => n is BRElement).toList();
195 expect(filtered.length, 1); 196 expect(filtered.length, 1);
196 expect(filtered[0], isBRElement); 197 expect(filtered[0], isBRElement);
197 expect(filtered, isNodeList); 198 expect(filtered, isNodeList);
198 }); 199 });
199 200
200 test('getRange', () { 201 test('getRange', () {
201 var range = makeNodeList().getRange(1, 2); 202 var range = makeNodeList().getRange(1, 2);
202 expect(range, isNodeList); 203 expect(range, isNodeList);
203 expect(range[0], isBRElement); 204 expect(range[0], isBRElement);
204 expect(range[1], isComment); 205 expect(range[1], isComment);
205 }); 206 });
206 }); 207 });
207 } 208 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698