Skip to content

Commit 7f22a0b

Browse files
ccocchieregon
authored andcommitted
Use isANode
1 parent a1d6037 commit 7f22a0b

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

core/array/shared/slice.rb

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,20 +744,28 @@ def to.to_int() -2 end
744744
@array.send(@method, eval("(-2...-4).step(10)")).should == []
745745
end
746746

747-
it "foos" do
748-
@array.send(@method, eval("(0..6).step(1)")).should == [0, 1, 2, 3, 4, 5]
749-
-> { @array.send(@method, eval("(0..6).step(2)")) }.should raise_error(RangeError, /out of range/)
750-
751-
@array.send(@method, eval("(1..6).step(2)")).should == [1, 3, 5]
752-
@array.send(@method, eval("(2..7).step(2)")).should == [2, 4]
753-
-> { @array.send(@method, eval("(2..8).step(2)")) }.should raise_error(RangeError, /out of range/)
754-
755-
@array.send(@method, eval("(6..1).step(-2)")).should == [5, 3, 1]
756-
@array.send(@method, eval("(7..2).step(-2)")).should == [5, 3]
757-
-> { @array.send(@method, eval("(8..2).step(-2)")) }.should raise_error(RangeError, /out of range/)
747+
it "has range with bounds outside of array" do
748+
# end is equal to array's length
749+
@array.send(@method, (0..6).step(1)).should == [0, 1, 2, 3, 4, 5]
750+
-> { @array.send(@method, (0..6).step(2)) }.should raise_error(RangeError)
751+
752+
# end is greater than length with positive steps
753+
@array.send(@method, (1..6).step(2)).should == [1, 3, 5]
754+
@array.send(@method, (2..7).step(2)).should == [2, 4]
755+
-> { @array.send(@method, (2..8).step(2)) }.should raise_error(RangeError)
756+
757+
# begin is greater than length with negative steps
758+
@array.send(@method, (6..1).step(-2)).should == [5, 3, 1]
759+
@array.send(@method, (7..2).step(-2)).should == [5, 3]
760+
-> { @array.send(@method, (8..2).step(-2)) }.should raise_error(RangeError)
761+
end
758762

763+
it "has endless range with start outside of array's bounds" do
759764
@array.send(@method, eval("(6..).step(1)")).should == []
760765
@array.send(@method, eval("(7..).step(1)")).should == nil
766+
767+
@array.send(@method, eval("(6..).step(2)")).should == []
768+
-> { @array.send(@method, eval("(7..).step(2)")) }.should raise_error(RangeError)
761769
end
762770
end
763771
end

0 commit comments

Comments
 (0)