summaryrefslogtreecommitdiff
path: root/spec/ruby/optional
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-28 08:35:48 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-28 08:35:48 +0000
commitd0fb73a0f0b82ebc0d3eb931c28686a2b9c40fef (patch)
tree7587165b00fd75037adcd1667a102bda5e9f3d09 /spec/ruby/optional
parent40efaab3012188e159d0f6e104371c22fc3fcafd (diff)
check enc_capable.
* encoding.c (rb_enc_capable): make it extern to check enc_capable. enc_index can be set to limited types such as T_STRING, T_REGEX and so on. This function check an object is this kind of types. * include/ruby/encoding.h: ditto. * encoding.c (enc_set_index): check a given object is enc_capable. * include/ruby/encoding.h (PUREFUNC): * marshal.c (encoding_name): check `rb_enc_capable` first. * marshal.c (r_ivar): ditto. If it is not enc_capable, it should be malformed data. * spec/ruby/optional/capi/encoding_spec.rb: remove tests depending on the wrong feature: all objects can set enc_index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r--spec/ruby/optional/capi/encoding_spec.rb24
1 files changed, 0 insertions, 24 deletions
diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb
index ba31c84f1c..cd3f00d478 100644
--- a/spec/ruby/optional/capi/encoding_spec.rb
+++ b/spec/ruby/optional/capi/encoding_spec.rb
@@ -12,24 +12,6 @@ describe :rb_enc_get_index, shared: true do
it "returns the index of the encoding of a Regexp" do
@s.send(@method, /regexp/).should >= 0
end
-
- it "returns the index of the encoding of an Object" do
- obj = mock("rb_enc_get_index string")
- @s.rb_enc_set_index(obj, 1)
- @s.send(@method, obj).should == 1
- end
-
- it "returns the index of the dummy encoding of an Object" do
- obj = mock("rb_enc_get_index string")
- index = Encoding.list.index(Encoding::UTF_16)
- @s.rb_enc_set_index(obj, index)
- @s.send(@method, obj).should == index
- end
-
- it "returns 0 for an object without an encoding" do
- obj = mock("rb_enc_get_index string")
- @s.send(@method, obj).should == 0
- end
end
describe :rb_enc_set_index, shared: true do
@@ -48,12 +30,6 @@ describe :rb_enc_set_index, shared: true do
result = @s.send(@method, str, 1)
result.first.should == result.last
end
-
- it "associates an encoding with an object" do
- obj = mock("rb_enc_set_index string")
- result = @s.send(@method, obj, 1)
- result.first.should == result.last
- end
end
describe "C-API Encoding function" do