summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-01 05:55:35 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-01 05:55:35 +0000
commit320ae01c5fb091eab0926c186f304a9caeda1ace (patch)
tree3cae4cb5ecf2fe06f3f063e3caf457b28202ae0b /test
parentac44784146cfe48eb09be56c629023bc47426651 (diff)
Object#clone with freeze: false [Feature #12300]
* object.c (rb_obj_clone2): Allow Object#clone to take freeze: false keyword argument to not freeze the clone. [ruby-core:75017][Feature #12300] * test/ruby/test_object.rb (TestObject): test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_object.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 62390ad5b5..599b2ae140 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -28,6 +28,22 @@ class TestObject < Test::Unit::TestCase
end
end
+ def test_clone
+ a = Object.new
+ def a.b; 2 end
+
+ a.freeze
+ c = a.clone
+ assert_equal(true, c.frozen?)
+ assert_equal(2, c.b)
+
+ d = a.clone(freeze: false)
+ def d.e; 3; end
+ assert_equal(false, d.frozen?)
+ assert_equal(2, d.b)
+ assert_equal(3, d.e)
+ end
+
def test_init_dupclone
cls = Class.new do
def initialize_clone(orig); throw :initialize_clone; end