new tests

This commit is contained in:
Laurent Sansonetti
2013-07-01 18:28:23 +02:00
parent 13b2e67fc9
commit eea624e43d

View File

@@ -8,12 +8,33 @@ describe "block dvars" do
test_block_dvars_proc.call.should == '123456'
end
it "change the store of related lvars" do
it "change the store of related lvars following the block definition" do
x = '123'
Proc.new { x += '456' }.call
lambda { x += '456' }.call
x.should == '123456'
end
it "change the store of related lvars following the block definition even if it's enclosed in another block" do
x = '123'
if Object.new # should not optimize
lambda { x += '456' }.call
end
x.should == '123456'
end
it "change the store of related lvars before the block definition" do
x = 1
again = true
while true
x += 1
1.times { x += 1 }
should_loop = again
again = false
break unless should_loop
end
x.should == 5
end
it "are released after the parent block is dispatched" do
$test_dealloc = false
autorelease_pool do
@@ -41,6 +62,34 @@ describe "block dvars" do
end
$test_dealloc.should == true
end
it "can be nested" do
x = 1
1.times do
x += 1
x.should == 2
1.times do
x += 1
x.should == 3
1.times do
x += 1
x.should == 4
1.times do
x += 1
x.should == 5
x += 1
end
x.should == 6
x += 1
end
x.should == 7
x += 1
end
x.should == 8
x += 1
end
x.should == 9
end
end
# http://hipbyte.myjetbrains.com/youtrack/issue/RM-190