summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-07-27 10:25:27 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-02 20:17:11 +0900
commit12a121cc0f7f5b438388288383a7b8b9baf3e2fe (patch)
treea82ed5807c74a6958284710790a92df47aa82b36
parent28001e55b3eb65e210484bc2b6f42e89c2903d49 (diff)
ENV.index: delete
Has been deprecated since 373282f6656d3d3d989d261e7a95f8e81b5c9712.
-rw-r--r--hash.c14
-rw-r--r--spec/ruby/core/env/index_spec.rb14
-rw-r--r--test/ruby/test_env.rb1
3 files changed, 8 insertions, 21 deletions
diff --git a/hash.c b/hash.c
index f951d59e96..132af403a7 100644
--- a/hash.c
+++ b/hash.c
@@ -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);
diff --git a/spec/ruby/core/env/index_spec.rb b/spec/ruby/core/env/index_spec.rb
index 43875f5a50..dfa40b6139 100644
--- a/spec/ruby/core/env/index_spec.rb
+++ b/spec/ruby/core/env/index_spec.rb
@@ -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
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index c1109cb2ef..7735b53045 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -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