Sha256: cabe0b64ec02801d4aa9c5810270e42ad1ff8f9a7612ec7beb6f8c48752dd5a7
Contents?: true
Size: 539 Bytes
Versions: 83
Compression:
Stored size: 539 Bytes
Contents
describe "Enumerable#cycle" do ruby_version_is '1.8.7' do it "returns nil and does nothing for non positive n or empty arrays" do [1,2,3].cycle(0){ throw "ball"}.should be_nil [].cycle(0){ throw "ball"}.should be_nil end it "cycle as many times as requested" do [1,2,3].cycle(2).to_a.should == [1,2,3,1,2,3] end it "loop indefinitely if no n" do bomb = 10 [1,2,3].cycle do bomb -= 1 break 42 if bomb <= 0 end.should == 42 bomb.should == 0 end end end
Version data entries
83 entries across 83 versions & 1 rubygems