1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ENV.index: delete

Has been deprecated since 373282f665.
This commit is contained in:
卜部昌平 2020-07-27 10:25:27 +09:00 committed by Nobuyoshi Nakada
parent 28001e55b3
commit 12a121cc0f
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
3 changed files with 8 additions and 21 deletions

14
hash.c
View file

@ -6251,19 +6251,6 @@ env_key(VALUE dmy, VALUE value)
return Qnil;
}
/*
* call-seq:
* ENV.index(value) -> name
*
* Deprecated method that is equivalent to ENV.key.
*/
static VALUE
env_index(VALUE dmy, VALUE value)
{
rb_warn_deprecated("ENV.index", "ENV.key");
return env_key(dmy, value);
}
static VALUE
env_to_hash(void)
{
@ -7137,7 +7124,6 @@ Init_Hash(void)
rb_define_singleton_method(envtbl, "to_a", env_to_a, 0);
rb_define_singleton_method(envtbl, "to_s", env_to_s, 0);
rb_define_singleton_method(envtbl, "key", env_key, 1);
rb_define_singleton_method(envtbl, "index", env_index, 1);
rb_define_singleton_method(envtbl, "size", env_size, 0);
rb_define_singleton_method(envtbl, "length", env_size, 0);
rb_define_singleton_method(envtbl, "empty?", env_empty_p, 0);

View file

@ -1,12 +1,14 @@
require_relative '../../spec_helper'
require_relative 'shared/key'
describe "ENV.index" do
it_behaves_like :env_key, :index
ruby_version_is ''...'2.8' do
describe "ENV.index" do
it_behaves_like :env_key, :index
it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
end
end
end

View file

@ -84,7 +84,6 @@ class TestEnv < Test::Unit::TestCase
ENV['test'] = val[0...-1]
assert_nil(ENV.key(val))
assert_nil(ENV.index(val))
assert_nil(ENV.key(val.upcase))
ENV['test'] = val
if IGNORE_CASE