aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-24 01:51:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-24 01:51:10 +0000
commitc4e8455ff167cfb80d8cbf3cfb7787938b6d4077 (patch)
tree261fdacbc12e9ee5274a745e1ecc70b9304ce293
parentab3611e2ccd279d70bf0a261b4fe01444fdd4bb6 (diff)
downloadruby-c4e8455ff167cfb80d8cbf3cfb7787938b6d4077.tar.gz
complex.c: undefine Comparable methods
* complex.c (Init_Complex): undefine methods inherited from Comparable, because Complex does not have <=> method. [Bug #12866] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--complex.c7
-rw-r--r--test/ruby/test_complex.rb10
3 files changed, 10 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 6177f568c0..d00b2c7644 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-Mon Oct 24 10:49:50 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Oct 24 10:51:09 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
diff --git a/complex.c b/complex.c
index ad1ea8514e..2544f3d9f7 100644
--- a/complex.c
+++ b/complex.c
@@ -2227,14 +2227,9 @@ Init_Complex(void)
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");
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 7d4358c087..a510a07dfa 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -749,13 +749,7 @@ class Complex_Test < Test::Unit::TestCase
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::TestCase
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