OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 pub_upgrade_test; | 5 library pub_upgrade_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 {bool fromLockFile: false}) => description; | 1371 {bool fromLockFile: false}) => description; |
1372 | 1372 |
1373 bool descriptionsEqual(description1, description2) => | 1373 bool descriptionsEqual(description1, description2) => |
1374 description1 == description2; | 1374 description1 == description2; |
1375 | 1375 |
1376 Future<String> getDirectory(PackageId id) { | 1376 Future<String> getDirectory(PackageId id) { |
1377 return new Future.value('${id.name}-${id.version}'); | 1377 return new Future.value('${id.name}-${id.version}'); |
1378 } | 1378 } |
1379 | 1379 |
1380 Future<List<Version>> getVersions(String name, String description) { | 1380 Future<List<Version>> getVersions(String name, String description) { |
1381 return syncFuture(() { | 1381 return new Future.sync(() { |
1382 // Make sure the solver doesn't request the same thing twice. | 1382 // Make sure the solver doesn't request the same thing twice. |
1383 if (_requestedVersions.contains(description)) { | 1383 if (_requestedVersions.contains(description)) { |
1384 throw new Exception('Version list for $description was already ' | 1384 throw new Exception('Version list for $description was already ' |
1385 'requested.'); | 1385 'requested.'); |
1386 } | 1386 } |
1387 | 1387 |
1388 _requestedVersions.add(description); | 1388 _requestedVersions.add(description); |
1389 | 1389 |
1390 if (!_packages.containsKey(description)){ | 1390 if (!_packages.containsKey(description)){ |
1391 throw new Exception('MockSource does not have a package matching ' | 1391 throw new Exception('MockSource does not have a package matching ' |
1392 '"$description".'); | 1392 '"$description".'); |
1393 } | 1393 } |
1394 | 1394 |
1395 return _packages[description].keys.toList(); | 1395 return _packages[description].keys.toList(); |
1396 }); | 1396 }); |
1397 } | 1397 } |
1398 | 1398 |
1399 Future<Pubspec> describeUncached(PackageId id) { | 1399 Future<Pubspec> describeUncached(PackageId id) { |
1400 return syncFuture(() { | 1400 return new Future.sync(() { |
1401 // Make sure the solver doesn't request the same thing twice. | 1401 // Make sure the solver doesn't request the same thing twice. |
1402 if (_requestedPubspecs.containsKey(id.description) && | 1402 if (_requestedPubspecs.containsKey(id.description) && |
1403 _requestedPubspecs[id.description].contains(id.version)) { | 1403 _requestedPubspecs[id.description].contains(id.version)) { |
1404 throw new Exception('Pubspec for $id was already requested.'); | 1404 throw new Exception('Pubspec for $id was already requested.'); |
1405 } | 1405 } |
1406 | 1406 |
1407 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); | 1407 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); |
1408 _requestedPubspecs[id.description].add(id.version); | 1408 _requestedPubspecs[id.description].add(id.version); |
1409 | 1409 |
1410 return _packages[id.description][id.version].pubspec; | 1410 return _packages[id.description][id.version].pubspec; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 } | 1512 } |
1513 | 1513 |
1514 var source = "mock1"; | 1514 var source = "mock1"; |
1515 if (match[7] != null) { | 1515 if (match[7] != null) { |
1516 source = match[7]; | 1516 source = match[7]; |
1517 if (source == "root") source = null; | 1517 if (source == "root") source = null; |
1518 } | 1518 } |
1519 | 1519 |
1520 return new PackageId(name, source, parsedVersion, description); | 1520 return new PackageId(name, source, parsedVersion, description); |
1521 } | 1521 } |
OLD | NEW |