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

Unified Diff: utils/tests/pub/version_test.dart

Issue 12310029: Allow whitespace in version constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't allow mixing "any" with other constraints. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/version.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tests/pub/version_test.dart
diff --git a/utils/tests/pub/version_test.dart b/utils/tests/pub/version_test.dart
index d5b1849870e84d4387d021390f53978a77a05c5c..7543298cc8388bfbe93a1a0474c8450f43b82f2d 100644
--- a/utils/tests/pub/version_test.dart
+++ b/utils/tests/pub/version_test.dart
@@ -10,6 +10,8 @@ import '../../pub/utils.dart';
import '../../pub/version.dart';
main() {
+ initConfig();
+
final v123 = new Version.parse('1.2.3');
final v114 = new Version.parse('1.1.4');
final v124 = new Version.parse('1.2.4');
@@ -386,12 +388,38 @@ main() {
new Version.parse('3.4.5')]));
});
- test('throws FormatException on a bad string', () {
- expect(() => new VersionConstraint.parse(''), throwsFormatException);
- expect(() => new VersionConstraint.parse(' '), throwsFormatException);
- expect(() => new VersionConstraint.parse('not a version'),
+ test('ignores whitespace around operators', () {
+ var constraint = new VersionConstraint.parse(' >1.0.0>=1.2.3 < 1.3.0');
+ expect(constraint, allows([
+ new Version.parse('1.2.3'),
+ new Version.parse('1.2.5')]));
+ expect(constraint, doesNotAllow([
+ new Version.parse('1.2.3-pre'),
+ new Version.parse('1.3.0'),
+ new Version.parse('3.4.5')]));
+ });
+
+ test('does not allow "any" to be mixed with other constraints', () {
+ expect(() => new VersionConstraint.parse('any 1.0.0'),
throwsFormatException);
});
+
+ test('throws FormatException on a bad string', () {
+ var bad = [
+ "", " ", // Empty string.
+ "foo", // Bad text.
+ ">foo", // Bad text after operator.
+ "1.0.0 foo", "1.0.0foo", // Bad text after version.
+ "anything", // Bad text after "any".
+ "<>1.0.0", // Multiple operators.
+ "1.0.0<" // Trailing operator.
+ ];
+
+ for (var text in bad) {
+ expect(() => new VersionConstraint.parse(text),
+ throwsFormatException);
+ }
+ });
});
});
}
« no previous file with comments | « utils/pub/version.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698