Skip to content

Commit 2162163

Browse files
committed
[Truffle] Add FileTest.
1 parent 6c64413 commit 2162163

19 files changed

+174
-72
lines changed

spec/truffle/tags/core/filetest/blockdev_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/truffle/tags/core/filetest/chardev_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
fails:FileTest.directory? returns true if the argument is a directory
2-
fails:FileTest.directory? returns false if the argument is not a directory
3-
fails:FileTest.directory? accepts an object that has a #to_path method
4-
fails:FileTest.directory? raises a TypeError when passed an Integer
5-
fails:FileTest.directory? raises a TypeError when passed nil
61
fails:FileTest.directory? returns false if the argument is an IO that's not a directory
72
fails:FileTest.directory? returns true if the argument is an IO that is a directory
83
fails:FileTest.directory? calls #to_io to convert a non-IO object

spec/truffle/tags/core/filetest/executable_real_tags.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

spec/truffle/tags/core/filetest/executable_tags.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

spec/truffle/tags/core/filetest/exist_tags.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

spec/truffle/tags/core/filetest/exists_tags.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
fails:FileTest.grpowned? returns true if the file exist
2-
fails:FileTest.grpowned? accepts an object that has a #to_path method
31
fails:FileTest.grpowned? takes non primary groups into account
4-
fails:FileTest.grpowned? returns false if the file doesn't exist

spec/truffle/tags/core/filetest/readable_real_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

spec/truffle/tags/core/filetest/readable_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
fails:FileTest.size? returns the size of the file if it exists and is not empty
2-
fails:FileTest.size? accepts a String-like (to_str) parameter
3-
fails:FileTest.size? accepts an object that has a #to_path method
4-
fails:FileTest.size? returns nil if file_name doesn't exist or has 0 size
5-
fails:FileTest.size? returns nil if file_name is empty
61
fails:FileTest.size? accepts a File argument
7-
fails:FileTest.size returns the size of the file if it exists and is not empty
8-
fails:FileTest.size accepts a String-like (to_str) parameter
9-
fails:FileTest.size accepts an object that has a #to_path method
10-
fails:FileTest.size raises an error if file_name doesn't exist
11-
fails:FileTest.size returns 0 if the file is empty
122
fails:FileTest.size accepts a File argument
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
fails:FileTest.sticky? returns false if the file dies not exist
21
fails:FileTest.sticky? returns true if the named file has the sticky bit, otherwise false

spec/truffle/tags/core/filetest/symlink_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/truffle/tags/core/filetest/writable_real_tags.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

spec/truffle/tags/core/filetest/writable_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

spec/truffle/tags/core/filetest/zero_tags.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

truffle/src/main/ruby/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
require_relative 'core/rubinius/common/file'
150150
require_relative 'core/rubinius/common/dir'
151151
require_relative 'core/rubinius/common/dir_glob'
152-
#require_relative 'core/rubinius/common/file_test'
152+
require_relative 'core/rubinius/common/file_test'
153153
require_relative 'core/rubinius/common/stat'
154154
require_relative 'core/rubinius/common/float'
155155
require_relative 'core/rubinius/common/immediate'
@@ -199,7 +199,7 @@
199199
#require_relative 'core/rubinius/delta/runtime'
200200
require_relative 'core/rubinius/delta/module'
201201
require_relative 'core/rubinius/delta/class'
202-
#require_relative 'core/rubinius/delta/file_test'
202+
require_relative 'core/rubinius/delta/file_test'
203203
require_relative 'core/rubinius/delta/kernel'
204204
#require_relative 'core/rubinius/delta/math'
205205
#require_relative 'core/rubinius/delta/options'
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Copyright (c) 2007-2014, Evan Phoenix and contributors
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright notice
10+
# this list of conditions and the following disclaimer in the documentation
11+
# and/or other materials provided with the distribution.
12+
# * Neither the name of Rubinius nor the names of its contributors
13+
# may be used to endorse or promote products derived from this software
14+
# without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
module FileTest
28+
def blockdev?(path)
29+
File.blockdev? path
30+
end
31+
32+
def chardev?(path)
33+
File.chardev? path
34+
end
35+
36+
def directory?(path)
37+
File.directory? path
38+
end
39+
40+
def executable?(path)
41+
File.executable? path
42+
end
43+
44+
def executable_real?(path)
45+
File.executable_real? path
46+
end
47+
48+
def exist?(path)
49+
File.exist? path
50+
end
51+
alias_method :exists?, :exist?
52+
53+
def file?(path)
54+
File.file? path
55+
end
56+
57+
def grpowned?(path)
58+
File.grpowned? path
59+
end
60+
61+
def identical?(a, b)
62+
File.identical? a, b
63+
end
64+
65+
def owned?(path)
66+
File.owned? path
67+
end
68+
69+
def pipe?(path)
70+
File.pipe? path
71+
end
72+
73+
def readable?(path)
74+
File.readable? path
75+
end
76+
77+
def readable_real?(path)
78+
File.readable_real? path
79+
end
80+
81+
def setgid?(path)
82+
File.setgid? path
83+
end
84+
85+
def setuid?(path)
86+
File.setuid? path
87+
end
88+
89+
def size(path)
90+
File.size path
91+
end
92+
93+
def size?(path)
94+
File.size? path
95+
end
96+
97+
def socket?(path)
98+
File.socket? path
99+
end
100+
101+
def sticky?(path)
102+
File.sticky? path
103+
end
104+
105+
def symlink?(path)
106+
File.symlink? path
107+
end
108+
109+
def writable?(path)
110+
File.writable? path
111+
end
112+
113+
def writable_real?(path)
114+
File.writable_real? path
115+
end
116+
117+
def zero?(path)
118+
File.zero? path
119+
end
120+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright (c) 2007-2014, Evan Phoenix and contributors
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# * Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright notice
10+
# this list of conditions and the following disclaimer in the documentation
11+
# and/or other materials provided with the distribution.
12+
# * Neither the name of Rubinius nor the names of its contributors
13+
# may be used to endorse or promote products derived from this software
14+
# without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
module FileTest
28+
module_function :blockdev?,
29+
:chardev?,
30+
:directory?,
31+
:executable?,
32+
:executable_real?,
33+
:exist?,
34+
:exists?,
35+
:file?,
36+
:grpowned?,
37+
:identical?,
38+
:owned?,
39+
:pipe?,
40+
:readable?,
41+
:readable_real?,
42+
:setgid?,
43+
:setuid?,
44+
:size,
45+
:size?,
46+
:socket?,
47+
:sticky?,
48+
:symlink?,
49+
:writable?,
50+
:writable_real?,
51+
:zero?
52+
end

0 commit comments

Comments
 (0)