diff options
author | Kenta Murata <mrkn@mrkn.jp> | 2020-01-17 10:41:03 +0900 |
---|---|---|
committer | Kenta Murata <mrkn@mrkn.jp> | 2020-01-17 10:57:21 +0900 |
commit | 47465ab1ccf48d2c905dbcf3b676e30b61cc41ca (patch) | |
tree | 365c04acbbc70374c1c6e66355dd9bbf3b8eb462 /test | |
parent | 73618d84e807b4157e0ba44e9a09e4c643de6c2c (diff) | |
download | ruby-47465ab1ccf48d2c905dbcf3b676e30b61cc41ca.tar.gz |
rb_rational_raw: make a denominator always positive
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/rational/test_rat.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/-ext-/rational/test_rat.rb b/test/-ext-/rational/test_rat.rb index 626ffb9661..dbba00ca61 100644 --- a/test/-ext-/rational/test_rat.rb +++ b/test/-ext-/rational/test_rat.rb @@ -29,4 +29,18 @@ class TestRational < Test::Unit::TestCase rescue NotImplementedError end end + + def test_rb_rational_raw + rat = Rational.raw(1, 2) + assert_equal(1, rat.numerator) + assert_equal(2, rat.denominator) + + rat = Rational.raw(-1, 2) + assert_equal(-1, rat.numerator) + assert_equal(2, rat.denominator) + + rat = Rational.raw(1, -2) + assert_equal(-1, rat.numerator) + assert_equal(2, rat.denominator) + end end |