aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/optional/capi/object_spec.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-27 10:48:40 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-27 10:48:40 +0000
commit3e6337b88b5255aba07b8f44de72cd5885f59465 (patch)
tree6146781aa381404b88ea4bfa2a44e75e8bc90d14 /spec/ruby/optional/capi/object_spec.rb
parentecc707e233a5577ea2048b3199d4baaf96c6b0f8 (diff)
downloadruby-3e6337b88b5255aba07b8f44de72cd5885f59465.tar.gz
Update to ruby/spec@8b743a3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional/capi/object_spec.rb')
-rw-r--r--spec/ruby/optional/capi/object_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb
index 7a817b7436..541b58b48c 100644
--- a/spec/ruby/optional/capi/object_spec.rb
+++ b/spec/ruby/optional/capi/object_spec.rb
@@ -813,6 +813,15 @@ describe "CApiObject" do
it "returns nil if the instance variable has not been initialized" do
@o.rb_ivar_get(@test, :@bar).should == nil
end
+
+ it "returns nil if the instance variable has not been initialized and is not a valid Ruby name" do
+ @o.rb_ivar_get(@test, :bar).should == nil
+ end
+
+ it 'returns the instance variable when it is not a valid Ruby name' do
+ @o.rb_ivar_set(@test, :foo, 27)
+ @o.rb_ivar_get(@test, :foo).should == 27
+ end
end
describe "rb_ivar_set" do
@@ -820,6 +829,15 @@ describe "CApiObject" do
@o.rb_ivar_set(@test, :@foo, 42).should == 42
@test.instance_eval { @foo }.should == 42
end
+
+ it "sets and returns the instance variable on an object" do
+ @o.rb_ivar_set(@test, :@foo, 42).should == 42
+ @test.instance_eval { @foo }.should == 42
+ end
+
+ it 'sets and returns the instance variable when it is not a valid Ruby name' do
+ @o.rb_ivar_set(@test, :foo, 27).should == 27
+ end
end
describe "rb_ivar_defined" do
@@ -830,6 +848,10 @@ describe "CApiObject" do
it "returns false if the instance variable is not defined" do
@o.rb_ivar_defined(@test, :@bar).should == false
end
+
+ it "does not throw an error if the instance variable is not a valid Ruby name" do
+ @o.rb_ivar_defined(@test, :bar).should == false
+ end
end
end
end