summaryrefslogtreecommitdiff
path: root/test/ruby/test_object.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-29 15:14:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-29 15:14:05 +0000
commitfe3b21bb8c00f20ad45822eb9d95c2e4058e5e5d (patch)
treefe8fe44e5e154ae24ec4452e7a522adbb7eed4d0 /test/ruby/test_object.rb
parent9e3afec027708a3c9919989eeed0d389c8a4c203 (diff)
object.c: no TypeError at special const clone
* object.c (rb_obj_clone2): no longer raise a TypeError for special constants, and return itself instead. however, if freeze option is false, raise an ArgumentError. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_object.rb')
-rw-r--r--test/ruby/test_object.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 2f80bc6ffb..dbe7e442ba 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -22,6 +22,7 @@ class TestObject < Test::Unit::TestCase
assert_equal 1, 1.dup
assert_equal true, true.dup
assert_equal nil, nil.dup
+ assert_equal false, false.dup
assert_raise(TypeError) do
Object.new.instance_eval { initialize_copy(1) }
@@ -37,11 +38,21 @@ class TestObject < Test::Unit::TestCase
assert_equal(true, c.frozen?)
assert_equal(2, c.b)
+ assert_raise(ArgumentError) {a.clone(freeze: [])}
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)
+
+ assert_equal 1, 1.clone
+ assert_equal true, true.clone
+ assert_equal nil, nil.clone
+ assert_equal false, false.clone
+ assert_raise(ArgumentError) {1.clone(freeze: false)}
+ assert_raise(ArgumentError) {true.clone(freeze: false)}
+ assert_raise(ArgumentError) {nil.clone(freeze: false)}
+ assert_raise(ArgumentError) {false.clone(freeze: false)}
end
def test_init_dupclone