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

Unified Diff: tests/standalone/io/platform_test.dart

Issue 921733002: Update documentation for Platform.version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 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 | « sdk/lib/io/platform.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/platform_test.dart
diff --git a/tests/standalone/io/platform_test.dart b/tests/standalone/io/platform_test.dart
index bf59383db3df661431e2adb61df9b7b54a17e4c8..a681694ba4fb33daa04cb9fc542dca169925e55b 100644
--- a/tests/standalone/io/platform_test.dart
+++ b/tests/standalone/io/platform_test.dart
@@ -66,9 +66,51 @@ testIsolate() {
});
}
+
+testVersion() {
+ checkValidVersion(string version) {
+ RegExp re = new RegExp(r'(\d+)\.(\d+)\.(\d+)(-dev\.([^\.]*)\.([^\.]*))?');
+ var match = re.firstMatch(version);
+ Expect.isNotNull(match);
+ // Major version.
+ Expect.isTrue(int.parse(match.group(1)) == 1);
+ // Minor version.
+ Expect.isTrue(int.parse(match.group(2)) >= 9);
+ // Patch version.
+ Expect.isTrue(int.parse(match.group(3)) >= 0);
+ // Dev
+ if (match.group(4) != null) {
+ // Dev prerelease minor version
+ Expect.isTrue(int.parse(match.group(5)) >= 0);
+ // Dev prerelease patch version
+ Expect.isTrue(int.parse(match.group(6)) >= 0);
+ }
+ }
+ // Ensure we can match valid versions.
+ checkValidVersion('1.9.0');
+ checkValidVersion('1.9.0-dev.0.0');
+ checkValidVersion('1.9.0-edge');
+ checkValidVersion('1.9.0-edge.r41234');
+ // Test current version.
+ checkValidVersion(Platform.version);
+ // Test some invalid versions.
+ Expect.throws(() => checkValidVersion('1.9'));
+ Expect.throws(() => checkValidVersion('2.0.0'));
+ Expect.throws(() => checkValidVersion('..'));
+ Expect.throws(() => checkValidVersion('1..'));
+ Expect.throws(() => checkValidVersion('1.9.'));
+ Expect.throws(() => checkValidVersion('1.9.0-dev..'));
+ Expect.throws(() => checkValidVersion('1.9.0-dev..0'));
+ Expect.throws(() => checkValidVersion('1.9.0-dev.0.'));
+ Expect.throws(() => checkValidVersion('1.9.0-dev.x.y'));
+ Expect.throws(() => checkValidVersion('x'));
+ Expect.throws(() => checkValidVersion('x.y.z'));
+}
+
main() {
// This tests assumes paths relative to dart main directory
Directory.current = Platform.script.resolve('../../..').toFilePath();
test();
testIsolate();
+ testVersion();
}
« no previous file with comments | « sdk/lib/io/platform.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698