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

Side by Side Diff: utils/tests/pub/pubspec_test.dart

Issue 10540151: First pass at version constraint solver. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Request all versions from the source, and not just the best. Created 8 years, 6 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
« no previous file with comments | « utils/pub/version_solver.dart ('k') | utils/tests/pub/version_solver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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('pubspec_test'); 5 #library('pubspec_test');
6 6
7 #import('../../../lib/unittest/unittest.dart'); 7 #import('../../../lib/unittest/unittest.dart');
8 #import('../../pub/pubspec.dart'); 8 #import('../../pub/pubspec.dart');
9 #import('../../pub/source.dart'); 9 #import('../../pub/source.dart');
10 #import('../../pub/source_registry.dart'); 10 #import('../../pub/source_registry.dart');
11 #import('../../pub/utils.dart'); 11 #import('../../pub/utils.dart');
12 #import('../../pub/version.dart');
12 13
13 class MockSource extends Source { 14 class MockSource extends Source {
14 final String name = "mock"; 15 final String name = "mock";
15 final bool shouldCache = false; 16 final bool shouldCache = false;
16 void validateDescription(description) { 17 void validateDescription(description) {
17 if (description != 'ok') throw new FormatException('Bad'); 18 if (description != 'ok') throw new FormatException('Bad');
18 } 19 }
19 } 20 }
20 21
21 main() { 22 main() {
22 group('Pubspec', () { 23 group('Pubspec', () {
23 group('parse()', () { 24 group('parse()', () {
25 test("allows a version constraint for dependencies", () {
26 var sources = new SourceRegistry();
27 sources.register(new MockSource());
28
29 var pubspec = new Pubspec.parse('''
30 dependencies:
31 foo:
32 mock: ok
33 version: ">=1.2.3 <3.4.5"
34 ''', sources);
35
36 var foo = pubspec.dependencies[0];
37 expect(foo.name, equals('foo'));
38 expect(foo.constraint.allows(new Version(1, 2, 3)));
39 expect(foo.constraint.allows(new Version(1, 2, 5)));
40 expect(!foo.constraint.allows(new Version(3, 4, 5)));
41 });
42
24 test("throws if the description isn't valid", () { 43 test("throws if the description isn't valid", () {
25 var sources = new SourceRegistry(); 44 var sources = new SourceRegistry();
26 sources.register(new MockSource()); 45 sources.register(new MockSource());
27 46
28 throwsBadFormat(() { 47 throwsBadFormat(() {
29 new Pubspec.parse(''' 48 new Pubspec.parse('''
30 dependencies: 49 dependencies:
31 foo: 50 foo:
32 mock: bad 51 mock: bad
33 ''', sources); 52 ''', sources);
34 }); 53 });
35 }); 54 });
36 }); 55 });
37 }); 56 });
38 } 57 }
39 58
40 throwsBadFormat(function) { 59 throwsBadFormat(function) {
41 expectThrow(function, (e) => e is FormatException); 60 expectThrow(function, (e) => e is FormatException);
42 } 61 }
OLDNEW
« no previous file with comments | « utils/pub/version_solver.dart ('k') | utils/tests/pub/version_solver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698