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

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

Issue 10850034: Rename BadNumberFormatException -> FormatException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years, 4 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/tests/pub/test_pub.dart ('k') | no next file » | 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('version_test'); 5 #library('version_test');
6 6
7 #import('../../../lib/unittest/unittest.dart'); 7 #import('../../../lib/unittest/unittest.dart');
8 #import('../../pub/utils.dart'); 8 #import('../../pub/utils.dart');
9 #import('../../pub/version.dart'); 9 #import('../../pub/version.dart');
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 new Version(1, 2, 3, pre: 'x.7.z-92'))); 114 new Version(1, 2, 3, pre: 'x.7.z-92')));
115 115
116 expect(new Version.parse('1.2.3+build.1'), equals( 116 expect(new Version.parse('1.2.3+build.1'), equals(
117 new Version(1, 2, 3, build: 'build.1'))); 117 new Version(1, 2, 3, build: 'build.1')));
118 expect(new Version.parse('1.2.3+x.7.z-92'), equals( 118 expect(new Version.parse('1.2.3+x.7.z-92'), equals(
119 new Version(1, 2, 3, build: 'x.7.z-92'))); 119 new Version(1, 2, 3, build: 'x.7.z-92')));
120 120
121 expect(new Version.parse('1.0.0-rc-1+build-1'), equals( 121 expect(new Version.parse('1.0.0-rc-1+build-1'), equals(
122 new Version(1, 0, 0, pre: 'rc-1', build: 'build-1'))); 122 new Version(1, 0, 0, pre: 'rc-1', build: 'build-1')));
123 123
124 throwsBadFormat(() => new Version.parse('1.0')); 124 expect(() => new Version.parse('1.0'), throwsFormatException);
125 throwsBadFormat(() => new Version.parse('1.2.3.4')); 125 expect(() => new Version.parse('1.2.3.4'), throwsFormatException);
126 throwsBadFormat(() => new Version.parse('1234')); 126 expect(() => new Version.parse('1234'), throwsFormatException);
127 throwsBadFormat(() => new Version.parse('-2.3.4')); 127 expect(() => new Version.parse('-2.3.4'), throwsFormatException);
128 throwsBadFormat(() => new Version.parse('1.3-pre')); 128 expect(() => new Version.parse('1.3-pre'), throwsFormatException);
129 throwsBadFormat(() => new Version.parse('1.3+build')); 129 expect(() => new Version.parse('1.3+build'), throwsFormatException);
130 throwsBadFormat(() => new Version.parse('1.3+bu?!3ild')); 130 expect(() => new Version.parse('1.3+bu?!3ild'), throwsFormatException);
131 }); 131 });
132 132
133 test('toString()', () { 133 test('toString()', () {
134 expect(new Version(0, 0, 0).toString(), equals('0.0.0')); 134 expect(new Version(0, 0, 0).toString(), equals('0.0.0'));
135 expect(new Version(12, 34, 56).toString(), equals('12.34.56')); 135 expect(new Version(12, 34, 56).toString(), equals('12.34.56'));
136 136
137 expect(new Version(1, 2, 3, pre: 'alpha.1').toString(), equals( 137 expect(new Version(1, 2, 3, pre: 'alpha.1').toString(), equals(
138 '1.2.3-alpha.1')); 138 '1.2.3-alpha.1'));
139 expect(new Version(1, 2, 3, pre: 'x.7.z-92').toString(), equals( 139 expect(new Version(1, 2, 3, pre: 'x.7.z-92').toString(), equals(
140 '1.2.3-x.7.z-92')); 140 '1.2.3-x.7.z-92'));
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 expect(constraint, allows([ 363 expect(constraint, allows([
364 new Version.parse('1.2.3'), 364 new Version.parse('1.2.3'),
365 new Version.parse('1.2.5')])); 365 new Version.parse('1.2.5')]));
366 expect(constraint, doesNotAllow([ 366 expect(constraint, doesNotAllow([
367 new Version.parse('1.2.3-pre'), 367 new Version.parse('1.2.3-pre'),
368 new Version.parse('1.3.0'), 368 new Version.parse('1.3.0'),
369 new Version.parse('3.4.5')])); 369 new Version.parse('3.4.5')]));
370 }); 370 });
371 371
372 test('throws FormatException on a bad string', () { 372 test('throws FormatException on a bad string', () {
373 throwsBadFormat(() => new VersionConstraint.parse('')); 373 expect(() => new VersionConstraint.parse(''), throwsFormatException);
374 throwsBadFormat(() => new VersionConstraint.parse(' ')); 374 expect(() => new VersionConstraint.parse(' '), throwsFormatException);
375 throwsBadFormat(() => new VersionConstraint.parse('not a version')); 375 expect(() => new VersionConstraint.parse('not a version'),
376 throwsFormatException);
376 }); 377 });
377 }); 378 });
378 }); 379 });
379 } 380 }
380 381
381 class VersionConstraintMatcher implements Matcher { 382 class VersionConstraintMatcher implements Matcher {
382 final List<Version> _expected; 383 final List<Version> _expected;
383 final bool _allow; 384 final bool _allow;
384 385
385 VersionConstraintMatcher(this._expected, this._allow); 386 VersionConstraintMatcher(this._expected, this._allow);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 422
422 Matcher allows(List<Version> versions) => 423 Matcher allows(List<Version> versions) =>
423 new VersionConstraintMatcher(versions, true); 424 new VersionConstraintMatcher(versions, true);
424 425
425 Matcher doesNotAllow(List<Version> versions) => 426 Matcher doesNotAllow(List<Version> versions) =>
426 new VersionConstraintMatcher(versions, false); 427 new VersionConstraintMatcher(versions, false);
427 428
428 throwsIllegalArg(function) { 429 throwsIllegalArg(function) {
429 expect(function, throwsA((e) => e is IllegalArgumentException)); 430 expect(function, throwsA((e) => e is IllegalArgumentException));
430 } 431 }
431
432 throwsBadFormat(function) {
433 expect(function, throwsA((e) => e is FormatException));
434 }
OLDNEW
« no previous file with comments | « utils/tests/pub/test_pub.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698