summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--build_config/host-f32.rb14
-rw-r--r--doc/guides/compile.md2
-rw-r--r--include/mruby/array.h2
-rw-r--r--mrbgems/mruby-cmath/src/cmath.c5
-rw-r--r--mrbgems/mruby-math/test/math.rb63
-rw-r--r--mrbgems/mruby-rational/src/rational.c4
-rw-r--r--mrbgems/mruby-sprintf/test/sprintf.rb10
-rw-r--r--mrbgems/mruby-test/driver.c4
-rw-r--r--tasks/test.rake4
9 files changed, 41 insertions, 67 deletions
diff --git a/build_config/host-f32.rb b/build_config/host-f32.rb
new file mode 100644
index 000000000..a449547ae
--- /dev/null
+++ b/build_config/host-f32.rb
@@ -0,0 +1,14 @@
+MRuby::Build.new do |conf|
+ # load specific toolchain settings
+ toolchain :gcc
+
+ # include the GEM box
+ conf.gembox 'default'
+
+ conf.cc.defines << 'MRB_USE_FLOAT32'
+
+ # Turn on `enable_debug` for better debugging
+ conf.enable_debug
+ conf.enable_test
+ conf.enable_bintest
+end
diff --git a/doc/guides/compile.md b/doc/guides/compile.md
index a8e35b65c..1e5314b95 100644
--- a/doc/guides/compile.md
+++ b/doc/guides/compile.md
@@ -11,7 +11,7 @@ To compile mruby out of the source code you need the following tools:
* Linker (e.g. `gcc` or `clang`)
* Archive utility (e.g. `ar`)
* Parser generator (`bison`)
-* Ruby 2.0 or later (e.g. `ruby` or `jruby`)
+* Ruby 2.5 or later (e.g. `ruby` or `jruby`)
Note that `bison` bundled with MacOS is too old to compile `mruby`.
Try `brew install bison` and follow the instruction shown to update
diff --git a/include/mruby/array.h b/include/mruby/array.h
index da811606a..10cc7849f 100644
--- a/include/mruby/array.h
+++ b/include/mruby/array.h
@@ -21,7 +21,7 @@ typedef struct mrb_shared_array {
mrb_value *ptr;
} mrb_shared_array;
-#if defined(MRB_32BIT) && defined(MRB_NO_BOXING)
+#if defined(MRB_32BIT) && defined(MRB_NO_BOXING) && !defined(MRB_USE_FLOAT32)
# define MRB_ARY_NO_EMBED
# define MRB_ARY_EMBED_LEN_MAX 0
#else
diff --git a/mrbgems/mruby-cmath/src/cmath.c b/mrbgems/mruby-cmath/src/cmath.c
index 857b58d26..8e94d1563 100644
--- a/mrbgems/mruby-cmath/src/cmath.c
+++ b/mrbgems/mruby-cmath/src/cmath.c
@@ -47,10 +47,10 @@ cmath_get_complex(mrb_state *mrb, mrb_value c, mrb_float *r, mrb_float *i)
#ifdef MRB_USE_FLOAT32
#define F(x) x##f
#else
-#endif
#define F(x) x
+#endif
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__MINGW32__)
#ifdef MRB_USE_FLOAT32
typedef _Fcomplex mrb_complex;
@@ -91,7 +91,6 @@ CXDIVc(mrb_complex a, mrb_complex b)
return CX(cr, ci);
}
-
#else
#if defined(__cplusplus) && defined(__APPLE__)
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-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c
index 9081c2eec..618ffa805 100644
--- a/mrbgems/mruby-rational/src/rational.c
+++ b/mrbgems/mruby-rational/src/rational.c
@@ -156,10 +156,10 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d)
if (d == 0) {
rat_zerodiv(mrb);
}
- a = i_gcd(n, d);
- if ((n == MRB_INT_MIN || d == MRB_INT_MIN) && a == -1) {
+ if (n == MRB_INT_MIN || d == MRB_INT_MIN) {
rat_overflow(mrb);
}
+ a = i_gcd(n, d);
return rational_new(mrb, n/a, d/a);
}
diff --git a/mrbgems/mruby-sprintf/test/sprintf.rb b/mrbgems/mruby-sprintf/test/sprintf.rb
index 8f99f9cd0..0a8166bae 100644
--- a/mrbgems/mruby-sprintf/test/sprintf.rb
+++ b/mrbgems/mruby-sprintf/test/sprintf.rb
@@ -10,11 +10,11 @@ assert('String#%') do
assert_equal 15, ("%b" % (1<<14)).size
skip unless Object.const_defined?(:Float)
assert_equal "1.0", "%3.1f" % 1.01
- assert_equal " 123456789.12", "% 4.2f" % 123456789.123456789
- assert_equal "123456789.12", "%-4.2f" % 123456789.123456789
- assert_equal "+123456789.12", "%+4.2f" % 123456789.123456789
- assert_equal "123456789.12", "%04.2f" % 123456789.123456789
- assert_equal "00000000123456789.12", "%020.2f" % 123456789.123456789
+ assert_equal " 1234567.12", "% 4.2f" % 1234567.123456789
+ assert_equal "1234567.12", "%-4.2f" % 1234567.123456789
+ assert_equal "+1234567.12", "%+4.2f" % 1234567.123456789
+ assert_equal "1234567.12", "%04.2f" % 1234567.123456789
+ assert_equal "00000000001234567.12", "%020.2f" % 1234567.123456789
end
assert('String#% with inf') do
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
diff --git a/tasks/test.rake b/tasks/test.rake
index 7dda40e39..32a03fce6 100644
--- a/tasks/test.rake
+++ b/tasks/test.rake
@@ -10,7 +10,7 @@ namespace :test do |test_ns|
end
desc "build and run command binaries tests"
- task :bin => :all do
+ task :bin => "rake:all" do
test_ns["run:bin"].invoke
end
@@ -19,7 +19,7 @@ namespace :test do |test_ns|
namespace :build do |test_build_ns|
desc "build library tests"
- task :lib => :all do
+ task :lib => "rake:all" do
MRuby.each_target{|build| build.gem(core: 'mruby-test')}
test = test_build_ns["lib_without_loading_gem"]
test.invoke if test