mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Remove specs trying arbitrary values for chmod and umask
* Instead assert that too large values raise RangeError. * [Bug #14375] [ruby-core:84933] * See https://github.com/ruby/ruby/pull/1797 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
429e2abfad
commit
7dc0bdb6e5
2 changed files with 9 additions and 122 deletions
|
@ -15,36 +15,9 @@ describe "File#chmod" do
|
|||
@file.chmod(0755).should == 0
|
||||
end
|
||||
|
||||
platform_is_not :freebsd, :netbsd, :openbsd, :darwin do
|
||||
it "always succeeds with any numeric values" do
|
||||
vals = [-2**30, -2**16, -2**8, -2, -1,
|
||||
-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { @file.chmod(v) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# -256, -2 and -1 raise Errno::EFTYPE on NetBSD
|
||||
platform_is :netbsd do
|
||||
it "always succeeds with any numeric values" do
|
||||
vals = [-2**30, -2**16, #-2**8, -2, -1,
|
||||
-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { @file.chmod(v) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# -256, -2 and -1 raise Errno::EINVAL on OpenBSD
|
||||
platform_is :freebsd, :openbsd, :darwin do
|
||||
it "always succeeds with any numeric values" do
|
||||
vals = [#-2**30, -2**16, -2**8, -2, -1,
|
||||
-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8]#, 2**16, 2**30
|
||||
vals.each { |v|
|
||||
lambda { @file.chmod(v) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
it "raises RangeError with too large values" do
|
||||
-> { @file.chmod(2**64) }.should raise_error(RangeError)
|
||||
-> { @file.chmod(-2**63 - 1) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "invokes to_int on non-integer argument" do
|
||||
|
@ -123,73 +96,9 @@ describe "File.chmod" do
|
|||
@count.should == 1
|
||||
end
|
||||
|
||||
platform_is_not :freebsd, :netbsd, :openbsd, :darwin do
|
||||
it "always succeeds with any numeric values" do
|
||||
vals = [-2**30, -2**16, -2**8, -2, -1,
|
||||
-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# -256, -2 and -1 raise Errno::EFTYPE on NetBSD
|
||||
platform_is :netbsd do
|
||||
it "always succeeds with any numeric values" do
|
||||
vals = [-2**30, -2**16, #-2**8, -2, -1,
|
||||
-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
platform_is :darwin do
|
||||
it "succeeds with valid values" do
|
||||
vals = [-2**8, -2, -1, -0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
|
||||
it "fails with invalid values" do
|
||||
vals = [-2**30, -2**16, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should raise_error(RangeError)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
platform_is :freebsd, :openbsd do
|
||||
it "succeeds with valid values" do
|
||||
vals = [-0.5, 0, 1, 2, 5.555575, 16, 32, 64, 2**8]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# -256, -2 and -1 raise Errno::EFTYPE on FreeBSD
|
||||
platform_is :freebsd do
|
||||
it "fails with invalid values" do
|
||||
vals = [-2**30, -2**16, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should raise_error(RangeError)
|
||||
}
|
||||
vals = [-2**8, -2, -1, 65535]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should raise_error(Errno::EFTYPE)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
platform_is :openbsd do
|
||||
it "fails with invalid values" do
|
||||
vals = [-2**30, -2**16, -2**8, -2, -1, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should raise_error(Errno::EINVAL)
|
||||
}
|
||||
end
|
||||
it "raises RangeError with too large values" do
|
||||
-> { File.chmod(2**64, @file) }.should raise_error(RangeError)
|
||||
-> { File.chmod(-2**63 - 1, @file) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "accepts an object that has a #to_path method" do
|
||||
|
|
|
@ -30,31 +30,9 @@ describe "File.umask" do
|
|||
end
|
||||
end
|
||||
|
||||
platform_is_not :freebsd, :darwin do
|
||||
it "always succeeds with any integer values" do
|
||||
vals = [-2**30, -2**16, -2**8, -2,
|
||||
-1.5, -1, 0.5, 0, 1, 2, 7.77777, 16, 32, 64, 2**8, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.umask(v) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
platform_is :freebsd, :darwin do
|
||||
it "always succeeds with any integer values" do
|
||||
vals = [-2**8, -2,
|
||||
-1.5, -1, 0.5, 0, 1, 2, 7.77777, 16, 32, 64, 2**8]
|
||||
vals.each { |v|
|
||||
lambda { File.umask(v) }.should_not raise_error
|
||||
}
|
||||
end
|
||||
|
||||
it "fails with invalid values" do
|
||||
vals = [-2**30, -2**16, 2**16, 2**30]
|
||||
vals.each { |v|
|
||||
lambda { File.chmod(v, @file) }.should raise_error(RangeError)
|
||||
}
|
||||
end
|
||||
it "raises RangeError with too large values" do
|
||||
-> { File.umask(2**64) }.should raise_error(RangeError)
|
||||
-> { File.umask(-2**63 - 1) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises ArgumentError when more than one argument is provided" do
|
||||
|
|
Loading…
Reference in a new issue