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

Unified Diff: packages/which/test/which_impl_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 | « packages/which/test/util.dart ('k') | packages/which/test/which_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/which/test/which_impl_test.dart
diff --git a/packages/which/test/which_impl_test.dart b/packages/which/test/which_impl_test.dart
new file mode 100755
index 0000000000000000000000000000000000000000..a5057804696083a63385268046ec0ae1876364d6
--- /dev/null
+++ b/packages/which/test/which_impl_test.dart
@@ -0,0 +1,55 @@
+
+library which.test.which_impl;
+
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+import 'package:which/src/which_impl.dart';
+
+import 'util.dart';
+
+main() {
+ group('which', () {
+ test('should complete to the first matching executable in candidate paths', () {
+ var candidatePaths = getPosixCandidatePaths('z', '/x/y:/a/b/c', '/foo/bar');
+
+ return which('z', candidatePaths, false, (path, isWindows) => new Future.value(path == '/x/y/z' || path == '/a/b/c/z'), null)
+ .then((path) => expect(path, '/x/y/z'));
+ });
+
+ test('should call orElse if command not found', () {
+ var candidatePaths = getPosixCandidatePaths('z', '/x/y:/a/b/c', '/foo/bar');
+
+ return which('z', candidatePaths, false, (path, isWindows) => new Future.value(false), () => '/or/else')
+ .then((path) => expect(path, '/or/else'));
+ });
+
+ test('should throw state error if command not found and orElse not provided', () {
+ var future = new Future(() =>
+ which('z', [], false, (path, isWindows) => new Future.value(false), null));
+
+ expect(future, throwsStateError);
+ });
+});
+
+ group('whichSync', () {
+ test('should return the first matching executable in candidate paths', () {
+ var candidatePaths = getWindowsCandidatePaths('z', r'C:\x\y;C:\a\b\c', '.EXE;.BAT', r'C:\foo\bar');
+
+ var result = whichSync('find', candidatePaths, true, (path, isWindows) => path == r'C:\x\y\z.BAT' || path == r'C:\a\b\c\z.BAT', null);
+
+ expect(result, r'C:\x\y\z.BAT');
+ });
+
+ test('should call orElse if command not found', () {
+ var candidatePaths = getWindowsCandidatePaths('z', r'C:\x\y;C:\a\b\c', '.EXE;.BAT', r'C:\foo\bar');
+
+ var result = whichSync('find', candidatePaths, true, (path, isWindows) => false, () => r'C:\or\else');
+
+ expect(result, r'C:\or\else');
+ });
+ test('should throw state error if command not found and orElse not provided', () {
+ expect(() => whichSync('z', [], true, (path, isWindows) => false, null), throwsStateError);
+ });
+ });
+}
« no previous file with comments | « packages/which/test/util.dart ('k') | packages/which/test/which_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698