From b31ba1056ee4647f188b997dcb47450bfe1cb25e Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 7 Mar 2018 11:54:07 +0000 Subject: complex.c: check type * complex.c (nucomp_s_canonicalize_internal): determine the type by the internal type, not by a method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_complex.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 316e3e21ff..48fb9947a3 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -958,4 +958,16 @@ class Complex_Test < Test::Unit::TestCase def test_known_bug end + def test_canonicalize_internal + obj = Class.new(Numeric) do + attr_accessor :real + alias real? real + end.new + obj.real = true + c = Complex.rect(obj, 1); + obj.real = false + c = c.conj + assert_equal(obj, c.real) + assert_equal(-1, c.imag) + end end -- cgit v1.2.3