ruby-changes:44410
From: nobu <ko1@a...>
Date: Mon, 24 Oct 2016 10:51:14 +0900 (JST)
Subject: [ruby-changes:44410] nobu:r56483 (trunk): complex.c: undefine Comparable methods
nobu 2016-10-24 10:51:10 +0900 (Mon, 24 Oct 2016) New Revision: 56483 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56483 Log: complex.c: undefine Comparable methods * complex.c (Init_Complex): undefine methods inherited from Comparable, because Complex does not have <=> method. [Bug #12866] Modified files: trunk/ChangeLog trunk/complex.c trunk/test/ruby/test_complex.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 56482) +++ ChangeLog (revision 56483) @@ -1,4 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Mon Oct 24 10:49:50 2016 Nobuyoshi Nakada <nobu@r...> +Mon Oct 24 10:51:09 2016 Nobuyoshi Nakada <nobu@r...> + + * complex.c (Init_Complex): undefine methods inherited from + Comparable, because Complex does not have <=> method. + [Bug #12866] * class.c (rb_undef_methods_from): undefine methods defined in super from klass. Index: test/ruby/test_complex.rb =================================================================== --- test/ruby/test_complex.rb (revision 56482) +++ test/ruby/test_complex.rb (revision 56483) @@ -749,13 +749,7 @@ class Complex_Test < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_complex.rb#L749 def test_respond c = Complex(1,1) assert_not_respond_to(c, :%) - assert_not_respond_to(c, :<) - assert_not_respond_to(c, :<=) assert_not_respond_to(c, :<=>) - assert_not_respond_to(c, :>) - assert_not_respond_to(c, :>=) - assert_not_respond_to(c, :between?) - assert_not_respond_to(c, :clamp) assert_not_respond_to(c, :div) assert_not_respond_to(c, :divmod) assert_not_respond_to(c, :floor) @@ -777,6 +771,10 @@ class Complex_Test < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_complex.rb#L771 assert_not_respond_to(c, :gcd) assert_not_respond_to(c, :lcm) assert_not_respond_to(c, :gcdlcm) + + (Comparable.instance_methods(false) - Complex.instance_methods(false)).each do |n| + assert_not_respond_to(c, n, "Complex##{n}") + end end def test_to_i Index: complex.c =================================================================== --- complex.c (revision 56482) +++ complex.c (revision 56483) @@ -2227,14 +2227,9 @@ Init_Complex(void) https://github.com/ruby/ruby/blob/trunk/complex.c#L2227 rb_define_global_function("Complex", nucomp_f_complex, -1); + rb_undef_methods_from(rb_cComplex, rb_mComparable); rb_undef_method(rb_cComplex, "%"); - rb_undef_method(rb_cComplex, "<"); - rb_undef_method(rb_cComplex, "<="); rb_undef_method(rb_cComplex, "<=>"); - rb_undef_method(rb_cComplex, ">"); - rb_undef_method(rb_cComplex, ">="); - rb_undef_method(rb_cComplex, "between?"); - rb_undef_method(rb_cComplex, "clamp"); rb_undef_method(rb_cComplex, "div"); rb_undef_method(rb_cComplex, "divmod"); rb_undef_method(rb_cComplex, "floor"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/