mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fixed float tolerance in tests when MRB_USE_FLOAT is set
This commit is contained in:
@@ -94,6 +94,12 @@ mrb_init_test_driver(mrb_state *mrb, mrb_bool verbose)
|
||||
mrb_define_const(mrb, mrbtest, "FIXNUM_MIN", mrb_fixnum_value(MRB_INT_MIN));
|
||||
mrb_define_const(mrb, mrbtest, "FIXNUM_BIT", mrb_fixnum_value(MRB_INT_BIT));
|
||||
|
||||
#ifdef MRB_USE_FLOAT
|
||||
mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-6));
|
||||
#else
|
||||
mrb_define_const(mrb, mrbtest, "FLOAT_TOLERANCE", mrb_float_value(mrb, 1e-12));
|
||||
#endif
|
||||
|
||||
if (verbose) {
|
||||
mrb_gv_set(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"), mrb_true_value());
|
||||
}
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ end
|
||||
##
|
||||
# Performs fuzzy check for equality on methods returning floats
|
||||
def check_float(a, b)
|
||||
tolerance = 1e-12
|
||||
tolerance = Mrbtest::FLOAT_TOLERANCE
|
||||
a = a.to_f
|
||||
b = b.to_f
|
||||
if a.finite? and b.finite?
|
||||
|
||||
Reference in New Issue
Block a user