Skip to content

Commit

Permalink
Merge pull request #26 from ksss/rbs-int_from_prime_division
Browse files Browse the repository at this point in the history
`.int_from_prime_division` could return Rational.
  • Loading branch information
hsbt authored Nov 19, 2024
2 parents 764192c + 7cae00f commit 1244e2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sig/prime.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Prime
# Prime.int_from_prime_division([[3, 2], [5, 1]]) #=> 45
# 3**2 * 5 #=> 45
#
def self.int_from_prime_division: (Array[[ Integer, Integer ]]) -> Integer
def self.int_from_prime_division: (Array[[ Integer, Integer ]]) -> (Integer | Rational)

# <!--
# rdoc-file=lib/prime.rb
Expand All @@ -160,7 +160,7 @@ class Prime
# Prime.int_from_prime_division([[3, 2], [5, 1]]) #=> 45
# 3**2 * 5 #=> 45
#
def int_from_prime_division: (Array[[ Integer, Integer ]]) -> Integer
def int_from_prime_division: (Array[[ Integer, Integer ]]) -> (Integer | Rational)

# <!--
# rdoc-file=lib/prime.rb
Expand Down
4 changes: 4 additions & 0 deletions test/test_rbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def test_each
def test_int_from_prime_division
assert_send_type "(::Array[[ ::Integer, ::Integer ]]) -> ::Integer",
Prime, :int_from_prime_division, [[3, 1], [19, 1]]
assert_send_type "(::Array[[ ::Integer, ::Integer ]]) -> ::Rational",
Prime, :int_from_prime_division, [[-4, -2]]
end

def test_prime?
Expand Down Expand Up @@ -85,6 +87,8 @@ def test_each
def test_int_from_prime_division
assert_send_type "(::Array[[ ::Integer, ::Integer ]]) -> ::Integer",
Prime.instance, :int_from_prime_division, [[3, 1], [19, 1]]
assert_send_type "(::Array[[ ::Integer, ::Integer ]]) -> ::Rational",
Prime.instance, :int_from_prime_division, [[-4, -2]]
end

def test_prime?
Expand Down

0 comments on commit 1244e2d

Please sign in to comment.