| OLD | NEW |
| 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 Loading... |
| 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 12 matching lines...) Expand all Loading... |
| 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) { |
| 254 if (object == null || object is num || object is String) { | 254 if (object == null || object is num || object is String || |
| 255 object is Uri || object is bool) { |
| 255 add(object); | 256 add(object); |
| 256 } else if (object is List) { | 257 } else if (object is List) { |
| 257 object.forEach(addJson); | 258 object.forEach(addJson); |
| 258 } else if (object is Map) { | 259 } else if (object is Map) { |
| 259 object.forEach((k, v) { addJson(k); addJson(value); }); | 260 for (var key in object.keys.toList()..sort()) { |
| 261 addJson(key); |
| 262 addJson(object[key]); |
| 263 } |
| 260 } else { | 264 } else { |
| 261 throw new Exception("Can't build hashcode for non json-like object " | 265 throw new Exception("Can't build hashcode for non json-like object " |
| 262 "(${object.runtimeType})"); | 266 "(${object.runtimeType})"); |
| 263 } | 267 } |
| 264 } | 268 } |
| 265 | 269 |
| 266 int get value => _value; | 270 int get value => _value; |
| 267 } | 271 } |
| 268 | 272 |
| 269 bool deepJsonCompare(Object a, Object b) { | 273 bool deepJsonCompare(Object a, Object b) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 298 | 302 |
| 299 class UniqueObject { | 303 class UniqueObject { |
| 300 static int _nextId = 1; | 304 static int _nextId = 1; |
| 301 final int _hashCode; | 305 final int _hashCode; |
| 302 | 306 |
| 303 int get hashCode => _hashCode; | 307 int get hashCode => _hashCode; |
| 304 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; | 308 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; |
| 305 | 309 |
| 306 UniqueObject() : _hashCode = ++_nextId; | 310 UniqueObject() : _hashCode = ++_nextId; |
| 307 } | 311 } |
| OLD | NEW |