diff options
Diffstat (limited to 'test/ruby/test_clone.rb')
| -rw-r--r-- | test/ruby/test_clone.rb | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/test/ruby/test_clone.rb b/test/ruby/test_clone.rb index 43c0cffa1d..321feb07c7 100644 --- a/test/ruby/test_clone.rb +++ b/test/ruby/test_clone.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require 'test/unit' class TestClone < Test::Unit::TestCase @@ -21,8 +22,43 @@ class TestClone < Test::Unit::TestCase assert_equal("test", bar.test) assert_equal("test", foo.test) - assert_raises(NoMethodError) {foo.test2} + assert_raise(NoMethodError) {foo.test2} assert_equal([M003, M002, M001], M003.ancestors) end + + def test_user_flags + assert_separately([], <<-EOS) + # + class Array + undef initialize_copy + def initialize_copy(*); end + end + x = [1, 2, 3].clone + assert_equal [], x, '[Bug #14847]' + EOS + + assert_separately([], <<-EOS) + # + class Array + undef initialize_copy + def initialize_copy(*); end + end + x = [1,2,3,4,5,6,7][1..-2].clone + x.push(1,1,1,1,1) + assert_equal [1, 1, 1, 1, 1], x, '[Bug #14847]' + EOS + + assert_separately([], <<-EOS) + # + class Hash + undef initialize_copy + def initialize_copy(*); end + end + h = {} + h.default_proc = proc { raise } + h = h.clone + assert_equal nil, h[:not_exist], '[Bug #14847]' + EOS + end end |
