diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-07 14:56:34 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-02-07 14:56:34 +0900 |
| commit | 1cc20978cfed14111c8962c4eee5370032c2557d (patch) | |
| tree | fbe3ce2b447918658c75eb9a3a163e38683fa73f | |
| parent | 3252518a3cfd6baa234ca861d4eeccbf158d28d2 (diff) | |
| download | mruby-1cc20978cfed14111c8962c4eee5370032c2557d.tar.gz mruby-1cc20978cfed14111c8962c4eee5370032c2557d.zip | |
Enlarge tolerance limit for `float32`; close #5329
Along with some refactoring on `mruby-math` tests.
| -rw-r--r-- | mrbgems/mruby-math/test/math.rb | 63 | ||||
| -rw-r--r-- | mrbgems/mruby-test/driver.c | 4 |
2 files changed, 14 insertions, 53 deletions
diff --git a/mrbgems/mruby-math/test/math.rb b/mrbgems/mruby-math/test/math.rb index 959eef788..6ea06151c 100644 --- a/mrbgems/mruby-math/test/math.rb +++ b/mrbgems/mruby-math/test/math.rb @@ -9,27 +9,18 @@ def assert_float_and_int(exp_ary, act_ary) end end -assert('Math.sin 0') do +assert('Math.sin') do assert_float(0, Math.sin(0)) -end - -assert('Math.sin PI/2') do assert_float(1, Math.sin(Math::PI / 2)) end -assert('Math.cos 0') do +assert('Math.cos') do assert_float(1, Math.cos(0)) -end - -assert('Math.cos PI/2') do assert_float(0, Math.cos(Math::PI / 2)) end -assert('Math.tan 0') do +assert('Math.tan') do assert_float(0, Math.tan(0)) -end - -assert('Math.tan PI/4') do assert_float(1, Math.tan(Math::PI / 4)) end @@ -49,52 +40,27 @@ assert('Fundamental trig identities') do end end -assert('Math.erf 0') do - assert_float(0, Math.erf(0)) -end - -assert('Math.exp 0') do +assert('Math.exp') do assert_float(1.0, Math.exp(0)) -end - -assert('Math.exp 1') do assert_float(2.718281828459045, Math.exp(1)) -end - -assert('Math.exp 1.5') do assert_float(4.4816890703380645, Math.exp(1.5)) end -assert('Math.log 1') do +assert('Math.log') do assert_float(0, Math.log(1)) -end - -assert('Math.log E') do assert_float(1.0, Math.log(Math::E)) -end - -assert('Math.log E**3') do assert_float(3.0, Math.log(Math::E**3)) end -assert('Math.log2 1') do +assert('Math.log2') do assert_float(0.0, Math.log2(1)) -end - -assert('Math.log2 2') do assert_float(1.0, Math.log2(2)) end -assert('Math.log10 1') do +assert('Math.log10') do assert_float(0.0, Math.log10(1)) -end - -assert('Math.log10 10') do assert_float(1.0, Math.log10(10)) -end - -assert('Math.log10 10**100') do - assert_float(100.0, Math.log10(10**100)) + assert_float(30.0, Math.log10(10**30)) end assert('Math.sqrt') do @@ -117,19 +83,14 @@ assert('Math.hypot') do assert_float(5.0, Math.hypot(3, 4)) end -assert('Math.erf 1') do +assert('Math.erf') do + assert_float(0, Math.erf(0)) assert_float(0.842700792949715, Math.erf(1)) -end - -assert('Math.erfc 1') do - assert_float(0.157299207050285, Math.erfc(1)) -end - -assert('Math.erf -1') do assert_float(-0.8427007929497148, Math.erf(-1)) end -assert('Math.erfc -1') do +assert('Math.erfc') do + assert_float(0.157299207050285, Math.erfc(1)) assert_float(1.8427007929497148, Math.erfc(-1)) end diff --git a/mrbgems/mruby-test/driver.c b/mrbgems/mruby-test/driver.c index d26233683..958e87dd1 100644 --- a/mrbgems/mruby-test/driver.c +++ b/mrbgems/mruby-test/driver.c @@ -226,9 +226,9 @@ mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose) #ifndef MRB_NO_FLOAT #ifdef MRB_USE_FLOAT32 - mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-6)); + mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-5)); #else - mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-12)); + mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-10)); #endif #endif |
