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

Side by Side Diff: packages/which/test/is_executable_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/has_permission_test.dart ('k') | packages/which/test/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.is_executable;
3
4 import 'dart:io';
5
6 import 'package:mockito/mockito.dart';
7 import 'package:unittest/unittest.dart';
8 import 'package:which/src/is_executable.dart';
9
10 import 'util.dart';
11
12 main() {
13 group('isExecutableStat', () {
14 test('false if not a file', () {
15
16 var stat = new MockFileStat();
17
18 // A directory.
19 when(stat.type).thenReturn(FileSystemEntityType.DIRECTORY);
20
21 var result = isExecutableStat(stat, false);
22
23 expect(result, isFalse);
24
25 verifyNever(stat.mode);
26 });
27
28 test('true for all files on windows', () {
29
30 var stat = new MockFileStat();
31
32 // A file.
33 when(stat.type).thenReturn(FileSystemEntityType.FILE);
34
35 var result = isExecutableStat(stat, true);
36
37 expect(result, isTrue);
38
39 verifyNever(stat.mode);
40 });
41
42 test('true if has world execute permission', () {
43 var result = isExecutableStat(_getMockFileStat('000000000001'), false);
44 expect(result, isTrue);
45 });
46
47 test('true if has group execute permission', () {
48 var result = isExecutableStat(_getMockFileStat('000000001000'), false);
49 expect(result, isTrue);
50 });
51
52 test('true if has owner execute permission', () {
53 var result = isExecutableStat(_getMockFileStat('000001000000'), false);
54 expect(result, isTrue);
55 });
56
57 test('false if has no execute permissions', () {
58 var result = isExecutableStat(_getMockFileStat('111110110110'), false);
59 expect(result, isFalse);
60 });
61 });
62 }
63
64 MockFileStat _getMockFileStat(String mode) {
65 var stat = new MockFileStat();
66
67 // A file.
68 when(stat.type).thenReturn(FileSystemEntityType.FILE);
69
70 // Last bit is world execute.
71 when(stat.mode).thenReturn(int.parse(mode, radix: 2));
72
73 return stat;
74 }
OLDNEW
« no previous file with comments | « packages/which/test/has_permission_test.dart ('k') | packages/which/test/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698