`Integer#pow(b)` accepts numeric

instead of integer only and returns numeric instead of integer only
same as `Integer#**`

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kazu 2017-12-06 15:02:31 +00:00
Родитель 956cfb974f
Коммит 49dc866492
2 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -7028,7 +7028,7 @@ int_pow_tmp2(VALUE x, VALUE y, long mm, int nega_flg)
/*
* Document-method: Integer#pow
* call-seq:
* integer.pow(integer) -> integer
* integer.pow(numeric) -> numeric
* integer.pow(integer, integer) -> integer
*
* Returns (modular) exponentiation as:

Просмотреть файл

@ -386,6 +386,10 @@ class TestNumeric < Test::Unit::TestCase
end
def test_pow
assert_equal(2**3, 2.pow(3))
assert_equal(2**-1, 2.pow(-1))
assert_equal(2**0.5, 2.pow(0.5))
assert_equal((-1)**0.5, -1.pow(0.5))
assert_equal(3**3 % 8, 3.pow(3, 8))
assert_equal(3**3 % -8, 3.pow(3,-8))
assert_equal(3**2 % -2, 3.pow(2,-2))