ruby-changes:63847
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 2 Dec 2020 20:24:28 +0900 (JST)
Subject: [ruby-changes:63847] 12a121cc0f (master): ENV.index: delete
https://git.ruby-lang.org/ruby.git/commit/?id=12a121cc0f From 12a121cc0f7f5b438388288383a7b8b9baf3e2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Mon, 27 Jul 2020 10:25:27 +0900 Subject: ENV.index: delete Has been deprecated since 373282f6656d3d3d989d261e7a95f8e81b5c9712. diff --git a/hash.c b/hash.c index f951d59..132af40 100644 --- a/hash.c +++ b/hash.c @@ -6251,19 +6251,6 @@ env_key(VALUE dmy, VALUE value) https://github.com/ruby/ruby/blob/trunk/hash.c#L6251 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) https://github.com/ruby/ruby/blob/trunk/hash.c#L7124 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 43875f5..dfa40b6 100644 --- a/spec/ruby/core/env/index_spec.rb +++ b/spec/ruby/core/env/index_spec.rb @@ -1,12 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/env/index_spec.rb#L1 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 c1109cb..7735b53 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -84,7 +84,6 @@ class TestEnv < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_env.rb#L84 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/