Skip to content

Commit 42b4eea

Browse files
committed
Add a spec for rb_obj_call_init passing blocks.
1 parent 07df635 commit 42b4eea

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/ruby/optional/capi/object_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def to_array
3030
class ObjectTest
3131
def initialize
3232
@foo = 7
33+
yield if block_given?
3334
end
3435

3536
def foo
@@ -88,6 +89,15 @@ def six(a, b, *c, &d); end
8889
o.initialized.should be_true
8990
o.arguments.should == [:one, :two]
9091
end
92+
93+
it "passes the block to #initialize" do
94+
v = nil
95+
o = @o.rb_obj_alloc(ObjectTest)
96+
@o.rb_obj_call_init(o, 0, []) do
97+
v = :foo
98+
end
99+
v.should == :foo
100+
end
91101
end
92102

93103
describe "rb_is_instance_of" do

0 commit comments

Comments
 (0)