From 3e6337b88b5255aba07b8f44de72cd5885f59465 Mon Sep 17 00:00:00 2001 From: eregon Date: Sat, 27 Oct 2018 10:48:40 +0000 Subject: Update to ruby/spec@8b743a3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/optional/capi/encoding_spec.rb | 8 ++++---- spec/ruby/optional/capi/object_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'spec/ruby/optional') diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb index 88b3e47833..583b33d736 100644 --- a/spec/ruby/optional/capi/encoding_spec.rb +++ b/spec/ruby/optional/capi/encoding_spec.rb @@ -139,21 +139,21 @@ describe "C-API Encoding function" do it_behaves_like :rb_enc_get_index, :rb_enc_get_index it "returns the index of the encoding of a Symbol" do - @s.send(@method, :symbol).should >= 0 + @s.rb_enc_get_index(:symbol).should >= 0 end it "returns -1 as the index of nil" do - @s.send(@method, nil).should == -1 + @s.rb_enc_get_index(nil).should == -1 end it "returns -1 as the index for immediates" do - @s.send(@method, 1).should == -1 + @s.rb_enc_get_index(1).should == -1 end ruby_version_is "2.6" do it "returns -1 for an object without an encoding" do obj = Object.new - @s.send(@method, obj).should == -1 + @s.rb_enc_get_index(obj).should == -1 end end end 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 -- cgit v1.2.3