diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-07-20 19:19:23 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-08-02 16:40:12 +0900 |
commit | ec3f59309e3f08339c4c76a6881901580801d6cd (patch) | |
tree | d5709cd6b5b17d4582a61d2492087fbd681db7d8 /test | |
parent | 3e4fedca4e0b068908137d44bcf5a567cb8445d0 (diff) |
[Bug #17767] Now `ENV.clone` raises `TypeError` as well as `ENV.dup`
One year ago, the former method has been deprecated while the latter
has become an error. Then the 3.1 released, it is enough time to make
also the former an error.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6155
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_env.rb | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index e9eaf144a1..cdadeac148 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -69,25 +69,20 @@ class TestEnv < Test::Unit::TestCase end def test_clone - warning = /ENV\.clone is deprecated; use ENV\.to_h instead/ - clone = assert_deprecated_warning(warning) { + message = /Cannot clone ENV/ + assert_raise_with_message(TypeError, message) { ENV.clone } - assert_same(ENV, clone) - - clone = assert_deprecated_warning(warning) { + assert_raise_with_message(TypeError, message) { ENV.clone(freeze: false) } - assert_same(ENV, clone) - - clone = assert_deprecated_warning(warning) { + assert_raise_with_message(TypeError, message) { ENV.clone(freeze: nil) } - assert_same(ENV, clone) - - assert_raise(TypeError) { + assert_raise_with_message(TypeError, message) { ENV.clone(freeze: true) } + assert_raise(ArgumentError) { ENV.clone(freeze: 1) } @@ -688,37 +683,6 @@ class TestEnv < Test::Unit::TestCase end; end - def test_clone_in_ractor - assert_ractor(<<-"end;") - r = Ractor.new do - original_warning_state = Warning[:deprecated] - Warning[:deprecated] = false - - begin - Ractor.yield ENV.clone.object_id - Ractor.yield ENV.clone(freeze: false).object_id - Ractor.yield ENV.clone(freeze: nil).object_id - - #{str_for_yielding_exception_class("ENV.clone(freeze: true)")} - #{str_for_yielding_exception_class("ENV.clone(freeze: 1)")} - #{str_for_yielding_exception_class("ENV.clone(foo: false)")} - #{str_for_yielding_exception_class("ENV.clone(1)")} - #{str_for_yielding_exception_class("ENV.clone(1, foo: false)")} - - ensure - Warning[:deprecated] = original_warning_state - end - end - assert_equal(ENV.object_id, r.take) - assert_equal(ENV.object_id, r.take) - assert_equal(ENV.object_id, r.take) - #{str_for_assert_raise_on_yielded_exception_class(TypeError, "r")} - 4.times do - #{str_for_assert_raise_on_yielded_exception_class(ArgumentError, "r")} - end - end; - end - def test_has_value_in_ractor assert_ractor(<<-"end;") r = Ractor.new do |