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

Side by Side Diff: tools/testing/dart/utils.dart

Issue 645533002: Clean up test_runner Command subclass hash/equality. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 utils; 5 library utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 import 'dart:convert'; 9 import 'dart:convert';
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 'safarimobilesim': const { 211 'safarimobilesim': const {
212 'macos': '/Applications/Xcode.app/Contents/Developer/Platforms/' 212 'macos': '/Applications/Xcode.app/Contents/Developer/Platforms/'
213 'iPhoneSimulator.platform/Developer/Applications/' 213 'iPhoneSimulator.platform/Developer/Applications/'
214 'iPhone Simulator.app/Contents/MacOS/iPhone Simulator' 214 'iPhone Simulator.app/Contents/MacOS/iPhone Simulator'
215 }, 215 },
216 'ie9': const { 216 'ie9': const {
217 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' 217 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
218 }, 218 },
219 'ie10': const { 219 'ie10': const {
220 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' 220 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
221 }, 221 },
222 'ie11': const { 222 'ie11': const {
223 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe' 223 'windows': 'C:\\Program Files\\Internet Explorer\\iexplore.exe'
224 }}; 224 }};
225 browserLocations['ff'] = browserLocations['firefox']; 225 browserLocations['ff'] = browserLocations['firefox'];
226 226
227 assert(browserLocations[browserName] != null); 227 assert(browserLocations[browserName] != null);
228 location = browserLocations[browserName][Platform.operatingSystem]; 228 location = browserLocations[browserName][Platform.operatingSystem];
229 if (location != null) { 229 if (location != null) {
230 return location; 230 return location;
231 } else { 231 } else {
(...skipping 11 matching lines...) Expand all
243 return argument; 243 return argument;
244 } 244 }
245 245
246 class HashCodeBuilder { 246 class HashCodeBuilder {
247 int _value = 0; 247 int _value = 0;
248 248
249 void add(Object object) { 249 void add(Object object) {
250 _value = ((_value * 31) ^ object.hashCode) & 0x3FFFFFFF; 250 _value = ((_value * 31) ^ object.hashCode) & 0x3FFFFFFF;
251 } 251 }
252 252
253 void addJson(Object object) { 253 void addJson(Object object) {
Bill Hesse 2014/10/09 12:03:50 This class is only used for test_runner.dart hashc
254 if (object == null || object is num || object is String) { 254 if (object == null || object is num || object is String || object is Uri) {
255 add(object); 255 add(object);
256 } else if (object is List) { 256 } else if (object is List) {
257 object.forEach(addJson); 257 object.forEach(addJson);
258 } else if (object is Map) { 258 } else if (object is Map) {
259 object.forEach((k, v) { addJson(k); addJson(value); }); 259 for (var key in object.keys.toList()..sort()) {
260 addJson(key);
261 addJson(object[key]);
262 }
260 } else { 263 } else {
261 throw new Exception("Can't build hashcode for non json-like object " 264 throw new Exception("Can't build hashcode for non json-like object "
262 "(${object.runtimeType})"); 265 "(${object.runtimeType})");
263 } 266 }
264 } 267 }
265 268
266 int get value => _value; 269 int get value => _value;
267 } 270 }
268 271
269 bool deepJsonCompare(Object a, Object b) { 272 bool deepJsonCompare(Object a, Object b) {
(...skipping 28 matching lines...) Expand all
298 301
299 class UniqueObject { 302 class UniqueObject {
300 static int _nextId = 1; 303 static int _nextId = 1;
301 final int _hashCode; 304 final int _hashCode;
302 305
303 int get hashCode => _hashCode; 306 int get hashCode => _hashCode;
304 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; 307 operator==(other) => other is UniqueObject && _hashCode == other._hashCode;
305 308
306 UniqueObject() : _hashCode = ++_nextId; 309 UniqueObject() : _hashCode = ++_nextId;
307 } 310 }
OLDNEW
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698