mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@8cafaa5
This commit is contained in:
parent
1b377b32c8
commit
2e32b919b4
35 changed files with 832 additions and 10 deletions
|
@ -117,6 +117,48 @@ describe "Kernel.rand" do
|
|||
end
|
||||
end
|
||||
|
||||
context "given an inclusive range between 0 and 1" do
|
||||
it "returns an Integer between the two Integers" do
|
||||
x = rand(0..1)
|
||||
x.should be_kind_of(Integer)
|
||||
(0..1).should include(x)
|
||||
end
|
||||
|
||||
it "returns a Float if at least one side is Float" do
|
||||
seed = 42
|
||||
x1 = Random.new(seed).rand(0..1.0)
|
||||
x2 = Random.new(seed).rand(0.0..1.0)
|
||||
x3 = Random.new(seed).rand(0.0..1)
|
||||
|
||||
x3.should be_kind_of(Float)
|
||||
x1.should equal(x3)
|
||||
x2.should equal(x3)
|
||||
|
||||
(0.0..1.0).should include(x3)
|
||||
end
|
||||
end
|
||||
|
||||
context "given an exclusive range between 0 and 1" do
|
||||
it "returns zero as an Integer" do
|
||||
x = rand(0...1)
|
||||
x.should be_kind_of(Integer)
|
||||
x.should eql(0)
|
||||
end
|
||||
|
||||
it "returns a Float if at least one side is Float" do
|
||||
seed = 42
|
||||
x1 = Random.new(seed).rand(0...1.0)
|
||||
x2 = Random.new(seed).rand(0.0...1.0)
|
||||
x3 = Random.new(seed).rand(0.0...1)
|
||||
|
||||
x3.should be_kind_of(Float)
|
||||
x1.should equal(x3)
|
||||
x2.should equal(x3)
|
||||
|
||||
(0.0...1.0).should include(x3)
|
||||
end
|
||||
end
|
||||
|
||||
it "returns a numeric for an range argument where max is < 1" do
|
||||
rand(0.25..0.75).should be_kind_of(Numeric)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue