File tree 2 files changed +30
-12
lines changed
spec/truffle/tags/core/kernel
truffle/src/main/ruby/core/rubinius/common
2 files changed +30
-12
lines changed Original file line number Diff line number Diff line change 1
- fails:Kernel#test is a private method
2
- fails:Kernel#test returns true when passed ?f if the argument is a regular file
3
- fails:Kernel#test returns true when passed ?e if the argument is a file
4
- fails:Kernel#test returns true when passed ?d if the argument is a directory
5
- fails:Kernel#test returns true when passed ?l if the argument is a symlink
6
- fails:Kernel#test returns true when passed ?r if the argument is readable by the effective uid
7
- fails:Kernel#test returns true when passed ?R if the argument is readable by the real uid
8
- fails:Kernel#test returns true when passed ?w if the argument is readable by the effective uid
9
- fails:Kernel#test returns true when passed ?W if the argument is readable by the real uid
10
- fails:Kernel#test calls #to_path on second argument when passed ?f and a filename
11
- fails:Kernel#test calls #to_path on second argument when passed ?e and a filename
12
- fails:Kernel#test calls #to_path on second argument when passed ?d and a directory
13
1
fails:Kernel#test time commands returns the last access time for the provided file when passed ?A
14
2
fails:Kernel#test time commands returns the time at which the file was created when passed ?C
15
3
fails:Kernel#test time commands returns the time at which the file was modified when passed ?M
Original file line number Diff line number Diff line change @@ -228,6 +228,36 @@ def tap
228
228
self
229
229
end
230
230
231
+ def test ( cmd , file1 , file2 = nil )
232
+ case cmd
233
+ when ?d
234
+ File . directory? file1
235
+ when ?e
236
+ File . exist? file1
237
+ when ?f
238
+ File . file? file1
239
+ when ?l
240
+ File . symlink? file1
241
+ when ?r
242
+ File . readable? file1
243
+ when ?R
244
+ File . readable_real? file1
245
+ when ?w
246
+ File . writable? file1
247
+ when ?W
248
+ File . writable_real? file1
249
+ when ?A
250
+ File . atime file1
251
+ when ?C
252
+ File . ctime file1
253
+ when ?M
254
+ File . mtime file1
255
+ else
256
+ raise NotImplementedError , "command ?#{ cmd . chr } not implemented"
257
+ end
258
+ end
259
+ module_function :test
260
+
231
261
def open ( obj , *rest , &block )
232
262
if obj . respond_to? ( :to_open )
233
263
obj = obj . to_open ( *rest )
You can’t perform that action at this time.
0 commit comments