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

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

Issue 15039023: Revert "dart2js native mixin application should extend 'Interface', not 'Object'" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('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 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 testUnsupported('fillRange', () { 329 testUnsupported('fillRange', () {
330 makeNodeWithChildren().nodes.fillRange(0, 1, null); 330 makeNodeWithChildren().nodes.fillRange(0, 1, null);
331 }); 331 });
332 332
333 testUnsupported('setAll', () { 333 testUnsupported('setAll', () {
334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]); 334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]);
335 }); 335 });
336 }); 336 });
337 337
338 group('NodeList', () { 338 group('_NodeList', () {
339 // Tests for methods on the DOM class 'NodeList'.
340 //
341 // There are two interesting things that are checked here from the viewpoint
342 // of the dart2js implementation of a 'native' class:
343 //
344 // 1. Some methods are implementated from by 'Object' or 'Interceptor';
345 // some of these tests simply check that a method can be called.
346 // 2. Some methods are implemented by mixins.
347
348 List<Node> makeNodeList() => 339 List<Node> makeNodeList() =>
349 (new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>")) 340 makeNodeWithChildren().nodes.where((_) => true).toList();
350 .$dom_getElementsByTagName('br');
351
352 test('trueNodeList', () {
353 var nodes = makeNodeList();
354 expect(nodes is NodeList, true);
355 });
356
357 test('hashCode', () {
358 var nodes = makeNodeList();
359 var hash = nodes.hashCode;
360 final int N = 1000;
361 int matchCount = 0;
362 for (int i = 0; i < N; i++) {
363 if (makeNodeList().hashCode == hash) matchCount++;
364 }
365 expect(matchCount, lessThan(N));
366 });
367
368 test('operator==', () {
369 var a = [makeNodeList(), makeNodeList(), null];
370 for (int i = 0; i < a.length; i++) {
371 for (int j = 0; j < a.length; j++) {
372 expect(i == j, a[i] == a[j]);
373 }
374 }
375 });
376
377 test('runtimeType', () {
378 var nodes1 = makeNodeList();
379 var nodes2 = makeNodeList();
380 var type1 = nodes1.runtimeType;
381 var type2 = nodes2.runtimeType;
382 expect(type1 == type2, true);
383 String name = '$type1';
384 if (name.length > 3) {
385 expect(name.contains('NodeList'), true);
386 }
387 });
388 341
389 test('first', () { 342 test('first', () {
390 var nodes = makeNodeList(); 343 var nodes = makeNodeList();
391 expect(nodes.first, isBRElement); 344 expect(nodes.first, isText);
392 });
393
394 test('last', () {
395 var nodes = makeNodeList();
396 expect(nodes.last, isBRElement);
397 }); 345 });
398 346
399 test('where', () { 347 test('where', () {
400 var filtered = makeNodeList().where((n) => n is BRElement).toList(); 348 var filtered = makeNodeList().where((n) => n is BRElement).toList();
401 expect(filtered.length, 3); 349 expect(filtered.length, 1);
402 expect(filtered[0], isBRElement); 350 expect(filtered[0], isBRElement);
403 expect(filtered, isNodeList); 351 expect(filtered, isNodeList);
404 }); 352 });
405 353
406 test('sublist', () { 354 test('sublist', () {
407 var range = makeNodeList().sublist(1, 3); 355 var range = makeNodeList().sublist(1, 3);
408 expect(range.length, 2); 356 expect(range, isNodeList);
409 expect(range[0], isBRElement); 357 expect(range[0], isBRElement);
410 expect(range[1], isBRElement); 358 expect(range[1], isComment);
411 }); 359 });
412
413 }); 360 });
414 361
415 group('iterating', () { 362 group('iterating', () {
416 test('NodeIterator', () { 363 test('NodeIterator', () {
417 var root = makeNodeWithChildren(); 364 var root = makeNodeWithChildren();
418 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT); 365 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT);
419 expect(nodeIterator.nextNode(), isComment); 366 expect(nodeIterator.nextNode(), isComment);
420 expect(nodeIterator.nextNode(), isNull); 367 expect(nodeIterator.nextNode(), isNull);
421 }); 368 });
422 369
423 test('TreeWalker', () { 370 test('TreeWalker', () {
424 var root = makeNodeWithChildren(); 371 var root = makeNodeWithChildren();
425 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT); 372 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT);
426 expect(treeWalker.nextNode(), isComment); 373 expect(treeWalker.nextNode(), isComment);
427 expect(treeWalker.nextNode(), isNull); 374 expect(treeWalker.nextNode(), isNull);
428 }); 375 });
429 }); 376 });
430 } 377 }
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698