mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@a6b8805
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6530b14cee
commit
8c5b60eb22
218 changed files with 4069 additions and 328 deletions
|
|
@ -10,13 +10,13 @@ describe :fiber_resume, shared: true do
|
|||
end
|
||||
|
||||
it "raises a FiberError if invoked from a different Thread" do
|
||||
fiber = Fiber.new { }
|
||||
lambda do
|
||||
Thread.new do
|
||||
fiber = Fiber.new { 42 }
|
||||
Thread.new do
|
||||
-> {
|
||||
fiber.resume
|
||||
end.join
|
||||
end.should raise_error(FiberError)
|
||||
fiber.resume
|
||||
}.should raise_error(FiberError)
|
||||
end.join
|
||||
fiber.resume.should == 42
|
||||
end
|
||||
|
||||
it "passes control to the beginning of the block on first invocation" do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe :rational_minus_rat, shared: true do
|
||||
it "returns the result of substracting other from self as a Rational" do
|
||||
it "returns the result of subtracting other from self as a Rational" do
|
||||
(Rational(3, 4) - Rational(0, 1)).should eql(Rational(3, 4))
|
||||
(Rational(3, 4) - Rational(1, 4)).should eql(Rational(1, 2))
|
||||
|
||||
|
|
@ -10,14 +10,14 @@ describe :rational_minus_rat, shared: true do
|
|||
end
|
||||
|
||||
describe :rational_minus_int, shared: true do
|
||||
it "returns the result of substracting other from self as a Rational" do
|
||||
it "returns the result of subtracting other from self as a Rational" do
|
||||
(Rational(3, 4) - 1).should eql(Rational(-1, 4))
|
||||
(Rational(3, 4) - 2).should eql(Rational(-5, 4))
|
||||
end
|
||||
end
|
||||
|
||||
describe :rational_minus_float, shared: true do
|
||||
it "returns the result of substracting other from self as a Float" do
|
||||
it "returns the result of subtracting other from self as a Float" do
|
||||
(Rational(3, 4) - 0.2).should eql(0.55)
|
||||
(Rational(3, 4) - 2.5).should eql(-1.75)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe :rational_plus_rat, shared: true do
|
||||
it "returns the result of substracting other from self as a Rational" do
|
||||
it "returns the result of subtracting other from self as a Rational" do
|
||||
(Rational(3, 4) + Rational(0, 1)).should eql(Rational(3, 4))
|
||||
(Rational(3, 4) + Rational(1, 4)).should eql(Rational(1, 1))
|
||||
|
||||
|
|
@ -10,14 +10,14 @@ describe :rational_plus_rat, shared: true do
|
|||
end
|
||||
|
||||
describe :rational_plus_int, shared: true do
|
||||
it "returns the result of substracting other from self as a Rational" do
|
||||
it "returns the result of subtracting other from self as a Rational" do
|
||||
(Rational(3, 4) + 1).should eql(Rational(7, 4))
|
||||
(Rational(3, 4) + 2).should eql(Rational(11, 4))
|
||||
end
|
||||
end
|
||||
|
||||
describe :rational_plus_float, shared: true do
|
||||
it "returns the result of substracting other from self as a Float" do
|
||||
it "returns the result of subtracting other from self as a Float" do
|
||||
(Rational(3, 4) + 0.2).should eql(0.95)
|
||||
(Rational(3, 4) + 2.5).should eql(3.25)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -68,4 +68,29 @@ describe :rational_round, shared: true do
|
|||
Rational(3, 2).round(2_097_171).should == Rational(3, 2)
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.4" do
|
||||
describe "with half option" do
|
||||
it "returns an Integer when precision is not passed" do
|
||||
Rational(10, 4).round(half: :up).should == 3
|
||||
Rational(10, 4).round(half: :down).should == 2
|
||||
Rational(10, 4).round(half: :even).should == 2
|
||||
Rational(-10, 4).round(half: :up).should == -3
|
||||
Rational(-10, 4).round(half: :down).should == -2
|
||||
Rational(-10, 4).round(half: :even).should == -2
|
||||
end
|
||||
|
||||
it "returns a Rational when the precision is greater than 0" do
|
||||
Rational(25, 100).round(1, half: :up).should == Rational(3, 10)
|
||||
Rational(25, 100).round(1, half: :down).should == Rational(1, 5)
|
||||
Rational(25, 100).round(1, half: :even).should == Rational(1, 5)
|
||||
Rational(35, 100).round(1, half: :up).should == Rational(2, 5)
|
||||
Rational(35, 100).round(1, half: :down).should == Rational(3, 10)
|
||||
Rational(35, 100).round(1, half: :even).should == Rational(2, 5)
|
||||
Rational(-25, 100).round(1, half: :up).should == Rational(-3, 10)
|
||||
Rational(-25, 100).round(1, half: :down).should == Rational(-1, 5)
|
||||
Rational(-25, 100).round(1, half: :even).should == Rational(-1, 5)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue