summaryrefslogtreecommitdiff
path: root/test/ruby/test_rational.rb
AgeCommit message (Collapse)Author
2019-07-11Check exception flag as a bool [Bug #15987]Nobuyoshi Nakada
2019-01-12No TypeError at nil if exception: falsenobu
[ruby-core:91021] [Bug #15525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08refine parse_ratnobu
* rational.c (read_num): return the exponent instead of the divisor, to get rid of huge bignums. * rational.c (parse_rat): subtract exponents instead of reduction of powers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-04bignum.c: Bignum#fdiv avoids double division when divisor is bignummame
`Rational(int, bignum).to_f` sometimes returned a wrong result because `Bignum#div` casted its divisor to double. [Bug #14637] [ruby-core:86330] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15Add `exception:` keyword in Kernel#Rational()mrkn
Support `exception:` keyword argument in `Kernel#Rational()`. If `exception:` is `false`, `Kernel#Rational()` returns `nil` if the given value cannot be interpreted as a rational value. The default value of `exception:` is `true`. This is part of [Feature #12732]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-27Support two `to_r`-responding args in Rational()mrkn
* rational.c (nurat_s_convert): call `to_r` to convert non-Numeric objects also if argc == 2 in Rational(). * test/ruby/test_rational.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-24test for r62555nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-24rational.c: segfault on Rational exponentnobu
* rational.c (read_num): fix segfault on Rational() with positive but less than the length of fractional part exponent. should be negated to convert to divisor which is a reciprocal. [ruby-core:85783] [Bug #14547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30force fixablenobu
* complex.c (nucomp_hash): force hash values fixable. [ruby-core:85224] [Bug #14420] * rational.c (nurat_hash): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24Fix a typoyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-19freeze Complex and Rationalnobu
* complex.c (nucomp_s_new_internal, nucomp_loader): Complex instances are always frozen now. [Feature #13983] * rational.c (nurat_s_new_internal, nurat_loader): Rational instances are always frozen now. [Feature #13983] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16rational.c: float denomnobu
* rational.c (parse_rat): allow float as a denominator as well as a numerator. [ruby-core:79104] [Bug #13134] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16rational.c: read_numnobu
* rational.c (read_num): use rb_int_parse_cstr to parse integer parts, and make String#to_r consistent with #to_i and #to_f. [ruby-core:80098] [Bug #13105] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16test_rational.rb: invalid exponentnobu
* test/ruby/test_rational.rb (test_parse): more checks for invalid exponent. [ruby-core:80098] [Bug #13105] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16test_rational.rb: duplicate assertionsnobu
* test/ruby/test_rational.rb (test_parse): remove duplicate assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16rational.c: zero divisionnobu
* rational.c (read_rat_nos): denominator cannot be 0, raise zero division in that case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-16test_rational.rb: shortennobu
* test/ruby/test_rational.rb (test_parse): reduce repeated arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22rational.c: infinity in powernobu
* rational.c (nurat_expt): return 0 due to overflow. [ruby-core:79686] [Bug #13242]: git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22rational.c: infinity in powernobu
* rational.c (nurat_expt): return Infinity due to overflow. [ruby-core:79686] [Bug #13242]: git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-16test_rational.rb: messagesnobu
* test/ruby/test_rational.rb (test_parse): add messages to assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-30rational.c: memory leak in gcdnobu
* rational.c (rb_gcd_gmp): fix memory leak. patched by KISHIMOTO, Makoto <ksmakoto AT dd.iij4u.or.jp> in [ruby-dev:49934]. [Bug #13089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-28numeric.c: reduce fdivnobu
* numeric.c (rb_int_fdiv_double): reduce first for more precise result. [ruby-core:78886] [Bug #13078] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10internal.h: change the default rounding mode to half-upmrkn
* internal.h (ROUND_DEFAULT): changed to RUBY_NUM_ROUND_HALF_UP. [Bug #12958] [ruby-core:78204] * test/ruby/test_integer.rb: fix assertions for the above change. * test/ruby/test_rational.rb: ditto. * test/test_mathn.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-29get rid of ambiguous parentheses warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-25round-downnobu
* numeric.c (round_half_down, int_round_half_down): support round-down mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11rational.c: check loadnobu
* rational.c (nurat_loader, nurat_marshal_load): check if loading values are Integer. [ruby-core:78071] [Bug #12918] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05numeric.c: round to nearest evennobu
* numeric.c (flo_round, int_round): support round-to-nearest-even semantics of IEEE 754 to match sprintf behavior, and add `half:` optional keyword argument for the old behavior. [ruby-core:76273] [Bug #12548] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-24refine assertionsnobu
* test/ruby/test_complex.rb, test/ruby/test_rational.rb: refine assertions for descriptive messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-17numeric.c, complex.c: Add finite? and infinite? consistent with Floatmrkn
* numeric.c (num_finite_p, num_infinite_p): Add Numeric#finite? and Numeric#infinite? [Feature #12039] [ruby-core:73618] * complex.c (rb_complex_finite_p): Add Complex#finite? * complex.c (rb_complex_infinite_p): Add Complex#infinite? * test/ruby/test_bignum.rb: Add test for Integer#finite? and Integer#infinite? * test/ruby/test_fixnum.rb: ditto. * test/ruby/test_rational.rb: Add test for Rational#finite? and Rational#infinite? * test/ruby/test_complex.rb: Add test for Complex#finite? and Complex#infinite? git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21hash method valuesnobu
* test/ruby/test_{complex,range,rational,struct}.rb (test_hash): hash values should be an Integer, not only a Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Use Integer instead of Fixnum and Bignum.akr
* object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-09assertions.rb: set default internal encodingnobu
* test/lib/test/unit/assertions.rb (assert_raise_with_message): set default internal encoding to the excpected message, which affects String#inspect in messages. * test/lib/test/unit/assertions.rb (assert_warning): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-19test/ruby: suppress runtime warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-19test/ruby: suppress parser warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12test_rational.rb: fix default externalnobu
* test/ruby/test_rational.rb (test_conv): fix default external encoding, which affects inspect results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12test_rational.rb: r51828nobu
* test/ruby/test_rational.rb (test_conv): test for r51828, encoding of exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-17numeric.c: Numeric#positive? and Numeric#negative?nobu
* numeric.c (num_positive_p, num_negative_p): add methods Numeric#positive? and Numeric#negative?. [ruby-core:69173] [Feature #11151] * numeric.c (flo_positive_p, flo_negative_p): specialiazed functions for Float. * complex.c (Init_Complex): Complex do not have positive? and negative? methods git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-27* test/ruby/test_complex.rb: removed unreachable code.hsbt
* test/ruby/test_rational.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26* test/ruby/test_complex.rb: cherry-picked working assertions from r47251.hsbt
* test/ruby/test_rational.rb: cherry-picked working assertions from r47263. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-24* test/ruby/test_complex.rb: removed needless conditions.hsbt
* test/ruby/test_rational.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-24* test/ruby/test_rational.rb: fixed indent.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-24* test/ruby/test_rational.rb: remove commented-out code.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13test/ruby: better assertionsnobu
* test/ruby: use better assertions instead of mere assert. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-05* rational.c (nurat_expt): Deal with special cases for rationals 0, ±1marcandre
[bug #5713] [bug #5715] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-26test_complex.rb, test_rational.rb: revert some assertionsnobu
* test_complex.rb, test_rational.rb: revert some assertions, but just assert that a frozen object cannot be modified with marshal_load. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-25complex.c, rational.c: compatible marshal loadernobu
* complex.c, rational.c: compatible marshal loader for compatibilities with 1.8. [ruby-core:45775] [Bug #6625] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22revert some teststadf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 * complex.c: wrote Complex#_dump and Complex::load. But nowtadf
disabled (due to compatibility) [experimental]. * rational.c: wrote Rational#_dump and Rational::load. ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-03 * complex.c (nucomp_marshal_load): [ruby-core:45394]tadf
* rational.c (nurat_marshal_load): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e