[前][次][番号順一覧][スレッド一覧]

ruby-changes:62140

From: Jeremy <ko1@a...>
Date: Mon, 6 Jul 2020 08:56:23 +0900 (JST)
Subject: [ruby-changes:62140] d36b197d7c (master): [ruby/bigdecimal] Remove definition of BigDecimal#initialize_copy

https://git.ruby-lang.org/ruby.git/commit/?id=d36b197d7c

From d36b197d7c1ce5684fb215697dc2d404cbd730d0 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Tue, 8 Oct 2019 15:23:46 -0700
Subject: [ruby/bigdecimal] Remove definition of BigDecimal#initialize_copy

This leaves the default definition, which will raise FrozenError.

https://github.com/ruby/bigdecimal/commit/05e843d838

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 3a46bd1..5d0fc85 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -3464,9 +3464,6 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3464
 
 
     /* instance methods */
-    rb_undef_method(rb_cBigDecimal, "initialize_copy");
-    rb_undef_method(rb_cBigDecimal, "initialize_clone");
-    rb_undef_method(rb_cBigDecimal, "initialize_dup");
     rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
 
     rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2);
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index 80ef39a..874338b 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -1884,10 +1884,12 @@ class TestBigDecimal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1884
     EOS
   end
 
-  def test_no_initialize_copy
-    assert_equal(false, BigDecimal(1).respond_to?(:initialize_copy, true))
-    assert_equal(false, BigDecimal(1).respond_to?(:initialize_dup, true))
-    assert_equal(false, BigDecimal(1).respond_to?(:initialize_clone, true))
+  def test_initialize_copy_dup_clone_frozen_error
+    bd = BigDecimal(1)
+    bd2 = BigDecimal(2)
+    assert_raise(FrozenError) { bd.send(:initialize_copy, bd2) }
+    assert_raise(FrozenError) { bd.send(:initialize_clone, bd2) }
+    assert_raise(FrozenError) { bd.send(:initialize_dup, bd2) }
   end
 
   def assert_no_memory_leak(code, *rest, **opt)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]