Skip to content
10 changes: 2 additions & 8 deletions core/complex.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class Complex < Numeric
#
# Complex.rect(1, 2).conj # => (1-2i)
#
def conj: () -> Complex
def conj: () -> self

# <!--
# rdoc-file=complex.c
Expand All @@ -387,7 +387,7 @@ class Complex < Numeric
#
# Complex.rect(1, 2).conj # => (1-2i)
#
def conjugate: () -> Complex
def conjugate: () -> self

# <!--
# rdoc-file=complex.c
Expand Down Expand Up @@ -522,8 +522,6 @@ class Complex < Numeric
#
def inspect: () -> String

def integer?: () -> bool

# <!-- rdoc-file=complex.c -->
# Returns the absolute value (magnitude) for `self`; see [polar
# coordinates](rdoc-ref:Complex@Polar+Coordinates):
Expand Down Expand Up @@ -745,8 +743,6 @@ class Complex < Numeric
#
def to_i: () -> Integer

alias to_int to_i

# <!--
# rdoc-file=complex.c
# - to_r -> rational
Expand Down Expand Up @@ -779,8 +775,6 @@ class Complex < Numeric
def to_s: () -> String

def truncate: (?Integer) -> bot

def zero?: () -> bool
end

# <!-- rdoc-file=complex.c -->
Expand Down
20 changes: 1 addition & 19 deletions core/float.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,10 @@ class Float < Numeric
#
def abs: () -> Float

def abs2: () -> Float

# <!-- rdoc-file=complex.c -->
# Returns 0 if `self` is positive, Math::PI otherwise.
#
def angle: () -> (Integer | Float)
def angle: ...

# <!--
# rdoc-file=complex.c
Expand Down Expand Up @@ -417,10 +415,6 @@ class Float < Numeric
#
def coerce: (Numeric) -> [ Float, Float ]

def conj: () -> Float

def conjugate: () -> Float

# <!--
# rdoc-file=rational.c
# - flo.denominator -> integer
Expand All @@ -431,8 +425,6 @@ class Float < Numeric
#
def denominator: () -> Integer

def div: (Numeric) -> Integer

# <!--
# rdoc-file=numeric.c
# - divmod(other) -> array
Expand Down Expand Up @@ -626,8 +618,6 @@ class Float < Numeric
#
alias inspect to_s

def integer?: () -> bool

# <!--
# rdoc-file=numeric.rb
# - magnitude()
Expand Down Expand Up @@ -823,14 +813,8 @@ class Float < Numeric
#
def rationalize: (?Numeric eps) -> Rational

def real: () -> Float

def real?: () -> true

def rect: () -> [ Float, Numeric ]

alias rectangular rect

def remainder: (Numeric) -> Float

# <!--
Expand Down Expand Up @@ -893,8 +877,6 @@ class Float < Numeric
| (?by: Numeric, ?to: Numeric) { (Float) -> void } -> self
| (?by: Numeric, ?to: Numeric) -> Enumerator[Float, self]

def to_c: () -> Complex

# <!--
# rdoc-file=numeric.rb
# - to_f -> self
Expand Down
22 changes: 0 additions & 22 deletions core/integer.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,6 @@ class Integer < Numeric
#
def abs: () -> Integer

def abs2: () -> Integer

# <!--
# rdoc-file=numeric.c
# - allbits?(mask) -> true or false
Expand All @@ -538,8 +536,6 @@ class Integer < Numeric
#
def allbits?: (int mask) -> bool

def angle: () -> (Integer | Float)

# <!--
# rdoc-file=numeric.c
# - anybits?(mask) -> true or false
Expand Down Expand Up @@ -704,10 +700,6 @@ class Integer < Numeric
#
def coerce: (Numeric) -> [ Numeric, Numeric ]

def conj: () -> Integer

def conjugate: () -> Integer

# <!--
# rdoc-file=numeric.rb
# - denominator -> 1
Expand Down Expand Up @@ -823,8 +815,6 @@ class Integer < Numeric
#
def fdiv: (Numeric) -> Float

def finite?: () -> bool

# <!--
# rdoc-file=numeric.c
# - floor(ndigits = 0) -> integer
Expand Down Expand Up @@ -895,8 +885,6 @@ class Integer < Numeric
#
def gcdlcm: (Integer) -> [ Integer, Integer ]

def infinite?: () -> Integer?

# <!-- rdoc-file=numeric.c -->
# Returns a string containing the place-value representation of `self` in radix
# `base` (in 2..36).
Expand Down Expand Up @@ -1027,8 +1015,6 @@ class Integer < Numeric
#
def ord: () -> Integer

alias phase angle

def polar: () -> [ Integer, Integer | Float ]

def positive?: () -> bool
Expand Down Expand Up @@ -1077,14 +1063,8 @@ class Integer < Numeric
#
def rationalize: (?Numeric eps) -> Rational

def real: () -> self

def real?: () -> true

def rect: () -> [ Integer, Numeric ]

alias rectangular rect

# <!--
# rdoc-file=numeric.c
# - remainder(other) -> real_number
Expand Down Expand Up @@ -1215,8 +1195,6 @@ class Integer < Numeric
def times: () { (Integer) -> void } -> self
| () -> ::Enumerator[Integer, self]

def to_c: () -> Complex

# <!--
# rdoc-file=numeric.c
# - to_f -> float
Expand Down
18 changes: 9 additions & 9 deletions core/numeric.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ class Numeric
# -->
# Returns the square of `self`.
#
def abs2: () -> Numeric
def abs2: () -> self

# <!-- rdoc-file=complex.c -->
# Returns zero if `self` is positive, Math::PI otherwise.
#
def angle: () -> Numeric
def angle: () -> (0 | Float)

# <!--
# rdoc-file=complex.c
Expand Down Expand Up @@ -310,18 +310,18 @@ class Numeric

# <!--
# rdoc-file=numeric.rb
# - conj()
# - conj -> self
# -->
# Returns `self`.
#
def conj: () -> Numeric
def conjugate: () -> self

# <!--
# rdoc-file=numeric.rb
# - conj -> self
# - conj()
# -->
# Returns `self`.
#
def conjugate: () -> Numeric
alias conj conjugate

# <!--
# rdoc-file=rational.c
Expand Down Expand Up @@ -590,15 +590,15 @@ class Numeric
# -->
# Returns `self`.
#
def real: () -> Numeric
def real: () -> self

# <!--
# rdoc-file=numeric.rb
# - real? -> true or false
# -->
# Returns `true` if `self` is a real number (i.e. not Complex).
#
def real?: () -> bool
def real?: () -> true

# <!-- rdoc-file=complex.c -->
# Returns array `[self, 0]`.
Expand Down
32 changes: 0 additions & 32 deletions core/rational.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ class Rational < Numeric
#
def abs: () -> Rational

def abs2: () -> Rational

def angle: () -> (Integer | Float)

alias arg angle

# <!--
# rdoc-file=rational.c
# - rat.ceil([ndigits]) -> integer or rational
Expand Down Expand Up @@ -220,10 +214,6 @@ class Rational < Numeric

def coerce: (Numeric) -> [ Numeric, Numeric ]

def conj: () -> Rational

def conjugate: () -> Rational

# <!--
# rdoc-file=rational.c
# - rat.denominator -> integer
Expand All @@ -237,8 +227,6 @@ class Rational < Numeric
#
def denominator: () -> Integer

def div: (Numeric) -> Integer

def divmod: (Integer | Float | Rational) -> [ Integer, Rational ]
| (Numeric) -> [ Numeric, Numeric ]

Expand All @@ -254,8 +242,6 @@ class Rational < Numeric
#
def fdiv: (Numeric) -> Float

def finite?: () -> bool

# <!--
# rdoc-file=rational.c
# - rat.floor([ndigits]) -> integer or rational
Expand Down Expand Up @@ -289,8 +275,6 @@ class Rational < Numeric
#
def hash: () -> Integer

def infinite?: () -> Integer?

# <!--
# rdoc-file=rational.c
# - rat.inspect -> string
Expand All @@ -303,8 +287,6 @@ class Rational < Numeric
#
def inspect: () -> String

def integer?: () -> bool

# <!-- rdoc-file=rational.c -->
# Returns the absolute value of `rat`.
#
Expand Down Expand Up @@ -337,8 +319,6 @@ class Rational < Numeric
#
def numerator: () -> Integer

alias phase angle

def polar: () -> [ Rational, Integer | Float ]

# <!--
Expand Down Expand Up @@ -377,14 +357,8 @@ class Rational < Numeric
#
def rationalize: (?Numeric eps) -> Rational

def real: () -> Rational

def real?: () -> true

def rect: () -> [ Rational, Numeric ]

alias rectangular rect

def remainder: (Float) -> Float
| (Numeric) -> Rational

Expand Down Expand Up @@ -431,8 +405,6 @@ class Rational < Numeric
| (?by: Numeric, ?to: Numeric) { (Rational) -> void } -> self
| (?by: Numeric, ?to: Numeric) -> Enumerator[Rational, self]

def to_c: () -> Complex

# <!--
# rdoc-file=rational.c
# - rat.to_f -> float
Expand Down Expand Up @@ -462,8 +434,6 @@ class Rational < Numeric
#
def to_i: () -> Integer

alias to_int to_i

# <!--
# rdoc-file=rational.c
# - rat.to_r -> self
Expand Down Expand Up @@ -512,6 +482,4 @@ class Rational < Numeric
#
def truncate: () -> Integer
| (Integer ndigits) -> (Integer | Rational)

def zero?: () -> bool
end
19 changes: 19 additions & 0 deletions test/stdlib/Complex_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,22 @@ 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

def test_abs2
assert_send_type '() -> Integer', Complex(1, 2), :abs2
assert_send_type '() -> Float', Complex.polar(2, 2), :abs2
end
end
7 changes: 0 additions & 7 deletions test/stdlib/Float_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ def test_coerce
2.5.coerce(1.1)
end

def test_conj
a = 31.4

a.conj
a.conjugate
end

def test_denominator
a = 13.3

Expand Down
Loading
Loading