From fb253d2032e51f333e6577aa4fcf0c03f9c6fc02 Mon Sep 17 00:00:00 2001 From: eregon Date: Fri, 3 Aug 2018 13:52:26 +0000 Subject: encoding.c (rb_enc_get_index): return -1 for non-encoding capable objects * Clarify logic and add spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/optional/capi/encoding_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spec/ruby/optional') diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb index 7661f2b68b..33587bf03a 100644 --- a/spec/ruby/optional/capi/encoding_spec.rb +++ b/spec/ruby/optional/capi/encoding_spec.rb @@ -147,6 +147,11 @@ describe "C-API Encoding function" do it "returns -1 as the index for immediates" do @s.send(@method, 1).should == -1 end + + it "returns -1 for an object without an encoding" do + obj = Object.new + @s.send(@method, obj).should == -1 + end end describe "rb_enc_set_index" do -- cgit v1.2.3