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

Side by Side Diff: packages/which/test/which_impl_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 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
« no previous file with comments | « packages/which/test/util.dart ('k') | packages/which/test/which_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
(Empty)
1
2 library which.test.which_impl;
3
4 import 'dart:async';
5
6 import 'package:unittest/unittest.dart';
7 import 'package:which/src/which_impl.dart';
8
9 import 'util.dart';
10
11 main() {
12 group('which', () {
13 test('should complete to the first matching executable in candidate paths', () {
14 var candidatePaths = getPosixCandidatePaths('z', '/x/y:/a/b/c', '/foo/bar' );
15
16 return which('z', candidatePaths, false, (path, isWindows) => new Future.v alue(path == '/x/y/z' || path == '/a/b/c/z'), null)
17 .then((path) => expect(path, '/x/y/z'));
18 });
19
20 test('should call orElse if command not found', () {
21 var candidatePaths = getPosixCandidatePaths('z', '/x/y:/a/b/c', '/foo/bar' );
22
23 return which('z', candidatePaths, false, (path, isWindows) => new Future.v alue(false), () => '/or/else')
24 .then((path) => expect(path, '/or/else'));
25 });
26
27 test('should throw state error if command not found and orElse not provided' , () {
28 var future = new Future(() =>
29 which('z', [], false, (path, isWindows) => new Future.value(false), nu ll));
30
31 expect(future, throwsStateError);
32 });
33 });
34
35 group('whichSync', () {
36 test('should return the first matching executable in candidate paths', () {
37 var candidatePaths = getWindowsCandidatePaths('z', r'C:\x\y;C:\a\b\c', '.E XE;.BAT', r'C:\foo\bar');
38
39 var result = whichSync('find', candidatePaths, true, (path, isWindows) => path == r'C:\x\y\z.BAT' || path == r'C:\a\b\c\z.BAT', null);
40
41 expect(result, r'C:\x\y\z.BAT');
42 });
43
44 test('should call orElse if command not found', () {
45 var candidatePaths = getWindowsCandidatePaths('z', r'C:\x\y;C:\a\b\c', '.E XE;.BAT', r'C:\foo\bar');
46
47 var result = whichSync('find', candidatePaths, true, (path, isWindows) => false, () => r'C:\or\else');
48
49 expect(result, r'C:\or\else');
50 });
51 test('should throw state error if command not found and orElse not provided' , () {
52 expect(() => whichSync('z', [], true, (path, isWindows) => false, null), t hrowsStateError);
53 });
54 });
55 }
OLDNEW
« 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