35 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 6f46f88873 numeric.c: fix: -0.0.abs returned -0.0. 2021-08-23 10:53:23 +09:00
Yukihiro "Matz" Matsumoto 8ca40da3fe test/float.rb: avoid 1.0e16 in tests without precision specified. 2021-08-21 15:25:59 +09:00
KOBAYASHI Shuji 6731f935cc Float::NAN/0 should be Float::NAN; ref a0b3378b3
#### Before this patch:

```console
$ bin/mruby -e 'p(Float::NAN/0)'
Infinity
```

#### After this patch (same as Ruby):

```console
$ bin/mruby -e 'p(Float::NAN/0)'
NaN
```
2021-03-18 17:10:51 +09:00
Yukihiro "Matz" Matsumoto f4a3dc4f07 Add tests for Integer#quo and Float#quo; #5268 2021-01-17 23:02:36 +09:00
Yukihiro "Matz" Matsumoto 1974aa0f72 Update Float#to_s to keep trailing zero as CRuby does; ref 68cebb6 2020-11-21 14:38:13 +09:00
KOBAYASHI Shuji 8bd1bc47b3 Always add trailing .0 in Float#inspect; ref #4225
Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at
9d08025b. However, I think the more human-readable format is better
for `Float#inspect`.

For example, in the `Float#to_s` format, the failure message is not
well understood when testing values including types by `eql?` (e.g.
`Numeric#step` test).

  ```ruby
  assert "example" do
    exp = 1.0
    act = 1
    assert_operator(exp, :eql?, act)  #=> Expected 1 to be eql? 1.
  end
  ```
2020-10-12 16:21:45 +09:00
Yukihiro "Matz" Matsumoto 8a87549315 Rename float configuration option names.
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT`
- `MRB_USE_FLOAT` => `MRB_USE_FLOAT32`

The former is to use `USE_XXX` naming convention. The latter is to make
sure `float` is 32bit float and not floating point number in general.
2020-10-12 16:21:40 +09:00
Yukihiro "Matz" Matsumoto 9d08025b8b Revert part of #4225
Since in mruby, Integer and Float interchange frequently (mostly on
overflow), so adding explicit `.0` can cause problems sometimes.

For example:
https://github.com/mattn/mruby-json/pull/40
https://github.com/pepabo/mruby-msd/pull/13
https://github.com/mattn/mruby-json/pull/42
2019-09-07 22:27:30 +09:00
KOBAYASHI Shuji 9f4147f28e Fix "ambiguous first argument" warning in test/t/float.rb 2019-04-23 21:02:42 +09:00
KOBAYASHI Shuji 0debf154ee Add assert_predicate and assert_operator 2019-04-22 22:26:11 +09:00
Yukihiro "Matz" Matsumoto f7e05c7d22 Update float test values to avoid precision errors. 2019-03-25 16:54:34 +09:00
Yukihiro "Matz" Matsumoto ce67561511 Avoid infinite binary floating numbers in float. 2019-03-25 16:21:50 +09:00
KOBAYASHI Shuji a41b02ab91 Fix Float#eql? 2019-03-21 21:36:54 +09:00
Yukihiro "Matz" Matsumoto 298807fa4e Avoid using infinite binary floating point numbers in tests. 2019-03-15 15:25:43 +09:00
KOBAYASHI Shuji 9f081183d2 Improve compatibility to CRuby for Float#to_s
Bfore:

  Float::INFINITY.to_s  #=> "inf"
  50.0.to_s             #=> "50"
  1e20.to_s             #=> "1e+20"

After / CRuby:

  Float::INFINITY.to_s  #=> "Infinity"
  50.0.to_s             #=> "50.0"
  1e20.to_s             #=> "1.0e+20"
2019-01-13 19:59:22 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00
Yukihiro "Matz" Matsumoto e14387440e Skip test/t/float.rb tests; ref #3827 2017-12-13 08:45:46 +09:00
ksss db3573e0bf Should raise FloatDomainError 2017-03-29 11:59:19 +09:00
cremno bb141e5532 fix ambiguous first argument warning
/home/travis/build/mruby/mruby/test/t/float.rb:201:17:
ambiguous first argument; put parentheses or even spaces
2015-11-06 18:35:19 +01:00
Yukihiro "Matz" Matsumoto 74696ffd96 Float << and >> should be more compatible to Fixnum 2015-09-02 22:29:01 +09:00
take_cheeze ec5b055694 Move direct superclass checking to test/t/superclass.rb. 2014-06-15 15:02:21 +09:00
ksss 8891cea41c Float#round fix bug for infinity and nan cases 2014-03-21 22:24:33 +09:00
ksss 0fab9d557e float + nil should be raise TypeError 2014-03-16 23:39:58 +09:00
Tomoyuki Sahara 9686890ab3 Fix Float#divmod. 2014-03-04 10:51:36 +09:00
Tomoyuki Sahara 7bf63c2876 add Float#nan? 2014-02-03 15:18:52 +09:00
Jun Hiroe edb0810c1a I fix order of actual and expect test value in float.rb. 2013-08-02 20:54:19 +09:00
Daniel Bovensiepen 8d38d9eaf1 Fix float parenthese warning 2013-06-14 22:16:38 +08:00
Daniel Bovensiepen 04191cc829 Improve Float Tests 2013-06-14 21:50:22 +08:00
Xuejie Xiao a9c8ae49eb Use check_float when testing equality for float values 2012-11-20 23:02:16 -05:00
Yukihiro Matsumoto 0270d11c81 float do not have enough precision to round if MRB_USE_FLOAT is set 2012-08-01 00:45:12 +09:00
Akira Kuroda 9dd3ac36d1 add test cases for floor, inifinite?, truncate, ceil, and round 2012-07-22 21:53:58 +09:00
Daniel Bovensiepen 0c2d74020a Add more superclass tests 2012-06-03 23:31:53 +08:00
Daniel Bovensiepen 31e9705022 Add Test cases for Literals, Enumeration, Exceptions and clean line endings 2012-05-29 01:20:46 +08:00
Yukihiro Matsumoto 52b2d092d3 test t/*.rb spacing fix 2012-05-23 12:00:49 +09:00
Daniel Bovensiepen 8bf21cdeae Finish all Float ISO Tests 2012-05-19 02:21:26 +08:00