mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@f8a2d54
This commit is contained in:
parent
ed377cc9aa
commit
809f0b8a13
76 changed files with 2451 additions and 224 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue