Chromium Code Reviews| Index: utils/tests/pub/version_solver_test.dart | 
| diff --git a/utils/tests/pub/version_solver_test.dart b/utils/tests/pub/version_solver_test.dart | 
| index 299ffaeb0aa5266d3cca177fac0b0349fd67042d..aa39dc69654f91ef320f5c0091d201ab57fd3563 100644 | 
| --- a/utils/tests/pub/version_solver_test.dart | 
| +++ b/utils/tests/pub/version_solver_test.dart | 
| @@ -17,6 +17,8 @@ | 
| final noVersion = 'no version'; | 
| final disjointConstraint = 'disjoint'; | 
| +final sourceMismatch = 'source mismatch'; | 
| +final descriptionMismatch = 'description mismatch'; | 
| final couldNotSolve = 'unsolved'; | 
| main() { | 
| @@ -104,20 +106,7 @@ main() { | 
| 'foo 1.0.0': { | 
| 'myapp': '>=1.0.0' | 
| } | 
| - }, result: { | 
| - 'myapp': '1.0.0', | 
| - 'foo': '1.0.0' | 
| - }); | 
| - | 
| - testResolve("dependency back onto root package that doesn't contain root's " | 
| - "version", { | 
| - 'myapp 1.0.0': { | 
| - 'foo': '1.0.0' | 
| - }, | 
| - 'foo 1.0.0': { | 
| - 'myapp': '>=2.0.0' | 
| - } | 
| - }, error: disjointConstraint); | 
| + }, error: sourceMismatch); | 
| 
 
Bob Nystrom
2012/06/29 17:24:40
Can you also add another test for sourceMismatch t
 
nweiz
2012/06/29 18:45:08
Done.
 
 | 
| testResolve('no version that matches requirement', { | 
| 'myapp 0.0.0': { | 
| @@ -157,6 +146,21 @@ main() { | 
| 'shared 4.0.0': {} | 
| }, error: disjointConstraint); | 
| + testResolve('mismatched descriptions', { | 
| + 'myapp 0.0.0': { | 
| + 'foo': '1.0.0', | 
| + 'bar': '1.0.0' | 
| + }, | 
| + 'foo 1.0.0': { | 
| + 'shared-x': '1.0.0' | 
| + }, | 
| + 'bar 1.0.0': { | 
| + 'shared-y': '1.0.0' | 
| + }, | 
| + 'shared-x 1.0.0': {}, | 
| + 'shared-y 1.0.0': {} | 
| + }, error: descriptionMismatch); | 
| + | 
| testResolve('unstable dependency graph', { | 
| 'myapp 0.0.0': { | 
| 'a': '>=1.0.0' | 
| @@ -218,6 +222,10 @@ testResolve(description, packages, [result, error]) { | 
| expect(future, throwsA(new isInstanceOf<NoVersionException>())); | 
| } else if (error == disjointConstraint) { | 
| expect(future, throwsA(new isInstanceOf<DisjointConstraintException>())); | 
| + } else if (error == sourceMismatch) { | 
| + expect(future, throwsA(new isInstanceOf<SourceMismatchException>())); | 
| + } else if (error == descriptionMismatch) { | 
| + expect(future, throwsA(new isInstanceOf<DescriptionMismatchException>())); | 
| } else if (error == couldNotSolve) { | 
| expect(future, throwsA(new isInstanceOf<CouldNotSolveException>())); | 
| } else { | 
| @@ -248,9 +256,9 @@ class MockSource extends Source { | 
| return fakeAsync(() => _packages[name].getKeys()); | 
| } | 
| - Future<Pubspec> describe(String package, Version version) { | 
| + Future<Pubspec> describe(PackageId id) { | 
| return fakeAsync(() { | 
| - return _packages[package][version].pubspec; | 
| + return _packages[id.name][id.version].pubspec; | 
| }); | 
| } | 
| @@ -262,8 +270,8 @@ class MockSource extends Source { | 
| // Build the pubspec dependencies. | 
| var dependencies = <PackageRef>[]; | 
| dependencyStrings.forEach((name, constraint) { | 
| - dependencies.add(new PackageRef(name, this, | 
| - new VersionConstraint.parse(constraint), name)); | 
| + dependencies.add(new PackageRef( | 
| + this, new VersionConstraint.parse(constraint), name)); | 
| }); | 
| var pubspec = new Pubspec(new Version.parse(version), dependencies); | 
| @@ -275,6 +283,9 @@ class MockSource extends Source { | 
| _packages[package.name][package.version] = package; | 
| return package; | 
| } | 
| + | 
| + String packageName(String name) => | 
| + name.replaceFirst(new RegExp(@"-[^-]+$"), ""); | 
| 
 
Bob Nystrom
2012/06/29 17:24:40
Please document this. It wasn't clear to me at fir
 
nweiz
2012/06/29 18:45:08
Done.
 
 | 
| } | 
| Future fakeAsync(callback()) { |