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 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' as svg; | 9 import 'dart:svg' as svg; |
10 | 10 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 }); | 234 }); |
235 | 235 |
236 test('removeLast', () { | 236 test('removeLast', () { |
237 var node = makeNodeWithChildren(); | 237 var node = makeNodeWithChildren(); |
238 expect(node.nodes.removeLast(), isComment); | 238 expect(node.nodes.removeLast(), isComment); |
239 expect(node.nodes.length, 2); | 239 expect(node.nodes.length, 2); |
240 expect(node.nodes.removeLast(), isBRElement); | 240 expect(node.nodes.removeLast(), isBRElement); |
241 expect(node.nodes.length, 1); | 241 expect(node.nodes.length, 1); |
242 }); | 242 }); |
243 | 243 |
244 test('getRange', () { | 244 test('sublist', () { |
245 var node = makeNodeWithChildren(); | 245 var node = makeNodeWithChildren(); |
246 expect(node.nodes.getRange(1, 2), isNodeList); | 246 expect(node.nodes.sublist(1, 3), isNodeList); |
247 }); | 247 }); |
248 }); | 248 }); |
249 | 249 |
250 group('_NodeList', () { | 250 group('_NodeList', () { |
251 List<Node> makeNodeList() => | 251 List<Node> makeNodeList() => |
252 makeNodeWithChildren().nodes.where((_) => true).toList(); | 252 makeNodeWithChildren().nodes.where((_) => true).toList(); |
253 | 253 |
254 test('first', () { | 254 test('first', () { |
255 var nodes = makeNodeList(); | 255 var nodes = makeNodeList(); |
256 expect(nodes.first, isText); | 256 expect(nodes.first, isText); |
257 }); | 257 }); |
258 | 258 |
259 test('where', () { | 259 test('where', () { |
260 var filtered = makeNodeList().where((n) => n is BRElement).toList(); | 260 var filtered = makeNodeList().where((n) => n is BRElement).toList(); |
261 expect(filtered.length, 1); | 261 expect(filtered.length, 1); |
262 expect(filtered[0], isBRElement); | 262 expect(filtered[0], isBRElement); |
263 expect(filtered, isNodeList); | 263 expect(filtered, isNodeList); |
264 }); | 264 }); |
265 | 265 |
266 test('getRange', () { | 266 test('sublist', () { |
267 var range = makeNodeList().getRange(1, 2); | 267 var range = makeNodeList().sublist(1, 3); |
268 expect(range, isNodeList); | 268 expect(range, isNodeList); |
269 expect(range[0], isBRElement); | 269 expect(range[0], isBRElement); |
270 expect(range[1], isComment); | 270 expect(range[1], isComment); |
271 }); | 271 }); |
272 }); | 272 }); |
273 } | 273 } |
OLD | NEW |