| 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_update_test; | 5 library pub_update_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 812 |
| 813 final String name; | 813 final String name; |
| 814 bool get shouldCache => true; | 814 bool get shouldCache => true; |
| 815 | 815 |
| 816 MockSource(this.name); | 816 MockSource(this.name); |
| 817 | 817 |
| 818 Future<List<Version>> getVersions(String name, String description) { | 818 Future<List<Version>> getVersions(String name, String description) { |
| 819 return new Future.sync(() { | 819 return new Future.sync(() { |
| 820 // Make sure the solver doesn't request the same thing twice. | 820 // Make sure the solver doesn't request the same thing twice. |
| 821 if (_requestedVersions.contains(description)) { | 821 if (_requestedVersions.contains(description)) { |
| 822 throw 'Version list for $description was already requested.'; | 822 throw new Exception('Version list for $description was already ' |
| 823 'requested.'); |
| 823 } | 824 } |
| 824 | 825 |
| 825 _requestedVersions.add(description); | 826 _requestedVersions.add(description); |
| 826 | 827 |
| 827 if (!_packages.containsKey(description)){ | 828 if (!_packages.containsKey(description)){ |
| 828 throw 'MockSource does not have a package matching "$description".'; | 829 throw new Exception('MockSource does not have a package matching ' |
| 830 '"$description".'); |
| 829 } | 831 } |
| 830 return _packages[description].keys.toList(); | 832 return _packages[description].keys.toList(); |
| 831 }); | 833 }); |
| 832 } | 834 } |
| 833 | 835 |
| 834 Future<Pubspec> describe(PackageId id) { | 836 Future<Pubspec> describe(PackageId id) { |
| 835 return new Future.sync(() { | 837 return new Future.sync(() { |
| 836 // Make sure the solver doesn't request the same thing twice. | 838 // Make sure the solver doesn't request the same thing twice. |
| 837 if (_requestedPubspecs.containsKey(id.description) && | 839 if (_requestedPubspecs.containsKey(id.description) && |
| 838 _requestedPubspecs[id.description].contains(id.version)) { | 840 _requestedPubspecs[id.description].contains(id.version)) { |
| 839 throw 'Pubspec for $id was already requested.'; | 841 throw new Exception('Pubspec for $id was already requested.'); |
| 840 } | 842 } |
| 841 | 843 |
| 842 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); | 844 _requestedPubspecs.putIfAbsent(id.description, () => new Set<Version>()); |
| 843 _requestedPubspecs[id.description].add(id.version); | 845 _requestedPubspecs[id.description].add(id.version); |
| 844 | 846 |
| 845 return _packages[id.description][id.version].pubspec; | 847 return _packages[id.description][id.version].pubspec; |
| 846 }); | 848 }); |
| 847 } | 849 } |
| 848 | 850 |
| 849 Future<bool> install(PackageId id, String path) { | 851 Future<bool> install(PackageId id, String path) { |
| 850 throw 'no'; | 852 throw new Exception('no'); |
| 851 } | 853 } |
| 852 | 854 |
| 853 void addPackage(String description, Package package) { | 855 void addPackage(String description, Package package) { |
| 854 _packages.putIfAbsent(description, () => new Map<Version, Package>()); | 856 _packages.putIfAbsent(description, () => new Map<Version, Package>()); |
| 855 _packages[description][package.version] = package; | 857 _packages[description][package.version] = package; |
| 856 } | 858 } |
| 857 } | 859 } |
| 858 | 860 |
| 859 Package mockPackage(String description, String version, | 861 Package mockPackage(String description, String version, |
| 860 Map dependencyStrings) { | 862 Map dependencyStrings) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 }; | 904 }; |
| 903 | 905 |
| 904 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); | 906 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); |
| 905 if (match != null) { | 907 if (match != null) { |
| 906 name = match[1]; | 908 name = match[1]; |
| 907 source = sourceNames[match[2]]; | 909 source = sourceNames[match[2]]; |
| 908 } | 910 } |
| 909 | 911 |
| 910 callback(isDev, name, source); | 912 callback(isDev, name, source); |
| 911 } | 913 } |
| OLD | NEW |