1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2020-01-28 20:47:48 +01:00
parent ed377cc9aa
commit 809f0b8a13
76 changed files with 2451 additions and 224 deletions

View file

@ -32,6 +32,28 @@ describe "Range#each" do
a.should == [x, y]
end
ruby_version_is "2.6" do
it "works with endless ranges" do
a = []
eval("(-2..)").each { |x| break if x > 2; a << x }
a.should == [-2, -1, 0, 1, 2]
a = []
eval("(-2...)").each { |x| break if x > 2; a << x }
a.should == [-2, -1, 0, 1, 2]
end
it "works with String endless ranges" do
a = []
eval("('A'..)").each { |x| break if x > "D"; a << x }
a.should == ["A", "B", "C", "D"]
a = []
eval("('A'...)").each { |x| break if x > "D"; a << x }
a.should == ["A", "B", "C", "D"]
end
end
it "raises a TypeError if the first element does not respond to #succ" do
-> { (0.5..2.4).each { |i| i } }.should raise_error(TypeError)