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

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

Issue 12670003: Add special treatement for typed arrays... (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/html/postmessage_structured_test.dart ('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 library TestUtils; 1 library TestUtils;
2
2 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html';
3 import '../../pkg/unittest/lib/unittest.dart'; 5 import '../../pkg/unittest/lib/unittest.dart';
4 6
5 /** 7 /**
6 * Verifies that [actual] has the same graph structure as [expected]. 8 * Verifies that [actual] has the same graph structure as [expected].
7 * Detects cycles and DAG structure in Maps and Lists. 9 * Detects cycles and DAG structure in Maps and Lists.
8 */ 10 */
9 verifyGraph(expected, actual) { 11 verifyGraph(expected, actual) {
10 var eItems = []; 12 var eItems = [];
11 var aItems = []; 13 var aItems = [];
12 14
(...skipping 18 matching lines...) Expand all
31 for (int i = 0; i < aItems.length; i++) { 33 for (int i = 0; i < aItems.length; i++) {
32 if (identical(actual, aItems[i])) { 34 if (identical(actual, aItems[i])) {
33 expect(expected, same(eItems[i]), 35 expect(expected, same(eItems[i]),
34 reason: message(path, 'extra back or side edge')); 36 reason: message(path, 'extra back or side edge'));
35 return; 37 return;
36 } 38 }
37 } 39 }
38 eItems.add(expected); 40 eItems.add(expected);
39 aItems.add(actual); 41 aItems.add(actual);
40 42
43 if (expected is ArrayBuffer) {
44 expect(actual is ArrayBuffer, isTrue,
45 reason: '$actual is ArrayBuffer');
46 expect(expected.byteLength, equals(actual.byteLength),
47 reason: message(path, '.byteLength'));
48 // TODO(antonm): one can create a view on top of those
49 // and check if contents identical. Let's do it later.
50 return;
51 }
52
53 if (expected is ArrayBufferView) {
54 expect(actual is ArrayBufferView, isTrue,
55 reason: '$actual is ArrayBufferView');
56 walk('$path/.buffer', expected.buffer, actual.buffer);
57 expect(expected.byteOffset, equals(actual.byteOffset),
58 reason: message(path, '.byteOffset'));
59 expect(expected.byteLength, equals(actual.byteLength),
60 reason: message(path, '.byteLength'));
61 // And also fallback to elements check below.
62 }
63
41 if (expected is List) { 64 if (expected is List) {
42 expect(actual, isList, reason: message(path, '$actual is List')); 65 expect(actual, isList, reason: message(path, '$actual is List'));
43 expect(actual.length, expected.length, 66 expect(actual.length, expected.length,
44 reason: message(path, 'different list lengths')); 67 reason: message(path, 'different list lengths'));
45 for (var i = 0; i < expected.length; i++) { 68 for (var i = 0; i < expected.length; i++) {
46 walk('$path[$i]', expected[i], actual[i]); 69 walk('$path[$i]', expected[i], actual[i]);
47 } 70 }
48 return; 71 return;
49 } 72 }
50 73
(...skipping 11 matching lines...) Expand all
62 } 85 }
63 } 86 }
64 return; 87 return;
65 } 88 }
66 89
67 expect(false, isTrue, reason: 'Unhandled type: $expected'); 90 expect(false, isTrue, reason: 'Unhandled type: $expected');
68 } 91 }
69 92
70 walk('', expected, actual); 93 walk('', expected, actual);
71 } 94 }
OLDNEW
« no previous file with comments | « tests/html/postmessage_structured_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698