From 2e09b1dc96a5f2aafef88743cc34320517bc7779 Mon Sep 17 00:00:00 2001 From: ksss Date: Tue, 22 Jul 2025 10:04:55 +0900 Subject: [PATCH 01/11] Remove undocumented `#conj` and `#conjugate` --- core/complex.rbs | 4 ++-- core/float.rbs | 4 ---- core/integer.rbs | 4 ---- core/numeric.rbs | 10 +++++----- core/rational.rbs | 4 ---- test/stdlib/Float_test.rb | 7 ------- test/stdlib/Integer_test.rb | 4 ---- test/stdlib/Rational_test.rb | 7 ------- 8 files changed, 7 insertions(+), 37 deletions(-) diff --git a/core/complex.rbs b/core/complex.rbs index 5126ab086..16d757ce0 100644 --- a/core/complex.rbs +++ b/core/complex.rbs @@ -377,7 +377,7 @@ class Complex < Numeric # # Complex.rect(1, 2).conj # => (1-2i) # - def conj: () -> Complex + def conj: () -> self # + # Returns `self`. # - def conj: () -> Numeric + def conjugate: () -> self # - # Returns `self`. # - def conjugate: () -> Numeric + alias conj conjugate # # Returns a string containing the place-value representation of `self` in radix # `base` (in 2..36). diff --git a/core/rational.rbs b/core/rational.rbs index bb800bd6a..0c598f6ff 100644 --- a/core/rational.rbs +++ b/core/rational.rbs @@ -250,8 +250,6 @@ class Rational < Numeric # def fdiv: (Numeric) -> Float - def finite?: () -> bool - # # Returns the absolute value (magnitude) for `self`; see [polar # coordinates](rdoc-ref:Complex@Polar+Coordinates): diff --git a/core/float.rbs b/core/float.rbs index 4ac8ece35..b0a36b475 100644 --- a/core/float.rbs +++ b/core/float.rbs @@ -622,8 +622,6 @@ class Float < Numeric # alias inspect to_s - def integer?: () -> bool - # # Returns the absolute value of `rat`. # From b2afdf85e8fba9c11f8860a451b093387d8a6335 Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 23 Jul 2025 10:03:27 +0900 Subject: [PATCH 04/11] Remove undocumented methods `#real` and `#real?` --- core/float.rbs | 4 ---- core/integer.rbs | 4 ---- core/numeric.rbs | 4 ++-- core/rational.rbs | 4 ---- test/stdlib/Complex_test.rb | 14 ++++++++++++++ test/stdlib/Numeric_test.rb | 19 +++++++++++++++++++ 6 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 test/stdlib/Numeric_test.rb diff --git a/core/float.rbs b/core/float.rbs index b0a36b475..fe346fa50 100644 --- a/core/float.rbs +++ b/core/float.rbs @@ -817,10 +817,6 @@ class Float < Numeric # def rationalize: (?Numeric eps) -> Rational - def real: () -> Float - - def real?: () -> true - def rect: () -> [ Float, Numeric ] alias rectangular rect diff --git a/core/integer.rbs b/core/integer.rbs index da88c0fec..b0eb1abd9 100644 --- a/core/integer.rbs +++ b/core/integer.rbs @@ -1069,10 +1069,6 @@ class Integer < Numeric # def rationalize: (?Numeric eps) -> Rational - def real: () -> self - - def real?: () -> true - def rect: () -> [ Integer, Numeric ] alias rectangular rect diff --git a/core/numeric.rbs b/core/numeric.rbs index 114e02477..de4ea286c 100644 --- a/core/numeric.rbs +++ b/core/numeric.rbs @@ -590,7 +590,7 @@ class Numeric # --> # Returns `self`. # - def real: () -> Numeric + def real: () -> self # # Returns `true` if `self` is a real number (i.e. not Complex). # - def real?: () -> bool + def real?: () -> true # # Returns array `[self, 0]`. diff --git a/core/rational.rbs b/core/rational.rbs index a9f87060d..343832656 100644 --- a/core/rational.rbs +++ b/core/rational.rbs @@ -367,10 +367,6 @@ class Rational < Numeric # def rationalize: (?Numeric eps) -> Rational - def real: () -> Rational - - def real?: () -> true - def rect: () -> [ Rational, Numeric ] alias rectangular rect diff --git a/test/stdlib/Complex_test.rb b/test/stdlib/Complex_test.rb index c8b00f206..8652ec1b4 100644 --- a/test/stdlib/Complex_test.rb +++ b/test/stdlib/Complex_test.rb @@ -130,3 +130,17 @@ def test_rationalize a.rationalize(3.11) end end + +class ComplexInstanceTest < Test::Unit::TestCase + include TestHelper + + testing 'Complex' + + def test_real + assert_send_type '() -> Integer', Complex(1, 2), :real + end + + def test_real? + assert_send_type '() -> false', Complex(1, 2), :real? + end +end diff --git a/test/stdlib/Numeric_test.rb b/test/stdlib/Numeric_test.rb new file mode 100644 index 000000000..e9d3e9bfd --- /dev/null +++ b/test/stdlib/Numeric_test.rb @@ -0,0 +1,19 @@ +require_relative "test_helper" + +class NumericInstanceTest < Test::Unit::TestCase + include TestHelper + + testing 'Numeric' + + def test_real + assert_send_type '() -> Integer', 1, :real + assert_send_type '() -> Float', 1.0, :real + assert_send_type '() -> Rational', 1r, :real + end + + def test_real? + assert_send_type '() -> true', 1, :real? + assert_send_type '() -> true', 1.0, :real? + assert_send_type '() -> true', 1r, :real? + end +end From ab3c04792568faad4e546c2d6c9c1192a45a468e Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 23 Jul 2025 10:08:28 +0900 Subject: [PATCH 05/11] Remove undocumented method `#zero?` --- core/complex.rbs | 2 -- core/rational.rbs | 2 -- test/stdlib/Numeric_test.rb | 5 +++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/complex.rbs b/core/complex.rbs index 829873900..b4de0a1d3 100644 --- a/core/complex.rbs +++ b/core/complex.rbs @@ -777,8 +777,6 @@ class Complex < Numeric def to_s: () -> String def truncate: (?Integer) -> bot - - def zero?: () -> bool end # diff --git a/core/rational.rbs b/core/rational.rbs index 343832656..085e5871a 100644 --- a/core/rational.rbs +++ b/core/rational.rbs @@ -498,6 +498,4 @@ class Rational < Numeric # def truncate: () -> Integer | (Integer ndigits) -> (Integer | Rational) - - def zero?: () -> bool end diff --git a/test/stdlib/Numeric_test.rb b/test/stdlib/Numeric_test.rb index e9d3e9bfd..e9d63cd47 100644 --- a/test/stdlib/Numeric_test.rb +++ b/test/stdlib/Numeric_test.rb @@ -16,4 +16,9 @@ def test_real? assert_send_type '() -> true', 1.0, :real? assert_send_type '() -> true', 1r, :real? end + + def test_zero? + assert_send_type '() -> bool', 0, :zero? + assert_send_type '() -> bool', 1r, :zero? + end end From 62a635006305f8af620f84fc072c2a78f868050f Mon Sep 17 00:00:00 2001 From: ksss Date: Wed, 23 Jul 2025 10:12:44 +0900 Subject: [PATCH 06/11] Remove undocumented method `#to_int` --- core/complex.rbs | 2 -- core/rational.rbs | 2 -- 2 files changed, 4 deletions(-) diff --git a/core/complex.rbs b/core/complex.rbs index b4de0a1d3..864d4e057 100644 --- a/core/complex.rbs +++ b/core/complex.rbs @@ -743,8 +743,6 @@ class Complex < Numeric # def to_i: () -> Integer - alias to_int to_i - # # Returns 0 if `self` is positive, Math::PI otherwise. # - def angle: () -> (Integer | Float) + def angle: ... # # Returns zero if `self` is positive, Math::PI otherwise. # - def angle: () -> Numeric + def angle: () -> (0 | Float) # # Returns 0 if `self` is positive, Math::PI otherwise. # diff --git a/core/integer.rbs b/core/integer.rbs index 4df3ea821..ba77fc430 100644 --- a/core/integer.rbs +++ b/core/integer.rbs @@ -513,8 +513,6 @@ class Integer < Numeric # def abs: () -> Integer - def abs2: () -> Integer - # # Returns the square of `self`. # - def abs2: () -> Numeric + def abs2: () -> self # # Returns zero if `self` is positive, Math::PI otherwise. diff --git a/core/rational.rbs b/core/rational.rbs index 64be7f346..46bcb75d9 100644 --- a/core/rational.rbs +++ b/core/rational.rbs @@ -186,8 +186,6 @@ class Rational < Numeric # def abs: () -> Rational - def abs2: () -> Rational - #