Sha256: 4518b4da11bd6c4b8d5766ecf2c8bb135034f5bc30f2029a15796fbd5dc2c24c
Contents?: true
Size: 880 Bytes
Versions: 6
Compression:
Stored size: 880 Bytes
Contents
describe "The break statement" do it "ends block execution if used within block" do a = [] lambda { a << 1 break a << 2 }.call a.should == [1] end it "causes block to return value passed to break" do lambda { break 123; 456 }.call.should == 123 end it "causes block to return nil if an empty expression passed to break" do lambda { break (); 456 }.call.should == nil end it "causes block to return nil if no value passed to break" do lambda { break; 456 }.call.should == nil end end # describe "Executing break from within a block" do # # it "returns from the invoking singleton method" do # obj = Object.new # def obj.meth_with_block # yield # raise "break didn't break from the singleton method" # end # obj.meth_with_block { break :value }.should == :value # end # end
Version data entries
6 entries across 6 versions & 1 rubygems