diff options
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-bin-debugger/bintest/print.rb | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 14 | ||||
| -rw-r--r-- | mrbgems/mruby-catch/mrblib/catch.rb | 24 | ||||
| -rw-r--r-- | mrbgems/mruby-catch/src/catch.c | 128 | ||||
| -rw-r--r-- | mrbgems/mruby-catch/test/catch.rb | 23 | ||||
| -rw-r--r-- | mrbgems/mruby-cmath/mrbgem.rake | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-cmath/src/cmath.c | 7 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 3 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/y.tab.c | 5 | ||||
| -rw-r--r-- | mrbgems/mruby-hash-ext/src/hash-ext.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-math/test/math.rb | 63 | ||||
| -rw-r--r-- | mrbgems/mruby-rational/src/rational.c | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-sleep/src/sleep.c (renamed from mrbgems/mruby-sleep/src/mrb_sleep.c) | 0 | ||||
| -rw-r--r-- | mrbgems/mruby-sprintf/test/sprintf.rb | 10 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/mrblib/struct.rb | 165 | ||||
| -rw-r--r-- | mrbgems/mruby-test/driver.c | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-test/mrbgem.rake | 6 |
17 files changed, 274 insertions, 190 deletions
diff --git a/mrbgems/mruby-bin-debugger/bintest/print.rb b/mrbgems/mruby-bin-debugger/bintest/print.rb index 4a4339f5a..63ebded3e 100644 --- a/mrbgems/mruby-bin-debugger/bintest/print.rb +++ b/mrbgems/mruby-bin-debugger/bintest/print.rb @@ -264,7 +264,7 @@ SRC BinTest_MrubyBinDebugger.test(src, tc) end -assert('mruby-bin-debugger(print) same name:instance variabe') do +assert('mruby-bin-debugger(print) same name:instance variable') do # ruby source (bp is break point) src = <<"SRC" @iv = 'top' @@ -296,7 +296,7 @@ SRC BinTest_MrubyBinDebugger.test(src, tc) end -# Kernel#instance_eval(string) does't work const. +# Kernel#instance_eval(string) doesn't work const. =begin assert('mruby-bin-debugger(print) same name:const') do # ruby source (bp is break point) diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 31a4e6fa1..e17f32a2e 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -14,17 +14,17 @@ #define C_EXT ".c" struct mrbc_args { - int argc; - char **argv; - int idx; const char *prog; const char *outfile; const char *initname; + char **argv; + int argc; + int idx; mrb_bool dump_struct : 1; mrb_bool check_syntax : 1; mrb_bool verbose : 1; mrb_bool remove_lv : 1; - unsigned int flags : 4; + uint8_t flags : 4; }; static void @@ -38,6 +38,7 @@ usage(const char *name) "-g produce debugging information", "-B<symbol> binary <symbol> output in C language format", "-S dump C struct (requires -B)", + "-s define <symbol> as static variable", "--remove-lv remove local variables", "--verbose run at verbose mode", "--version print the version", @@ -131,7 +132,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args) args->verbose = TRUE; break; case 'g': - args->flags |= DUMP_DEBUG_INFO; + args->flags |= MRB_DUMP_DEBUG_INFO; + break; + case 's': + args->flags |= MRB_DUMP_STATIC; break; case 'E': case 'e': diff --git a/mrbgems/mruby-catch/mrblib/catch.rb b/mrbgems/mruby-catch/mrblib/catch.rb index 68b165c8d..9a60a67a3 100644 --- a/mrbgems/mruby-catch/mrblib/catch.rb +++ b/mrbgems/mruby-catch/mrblib/catch.rb @@ -1,22 +1,8 @@ -class ThrowCatchJump < Exception - attr_reader :_tag, :_val - def initialize(tag, val) - @_tag = tag - @_val = val +class UncaughtThrowError < ArgumentError + attr_reader :tag, :value + def initialize(tag, value) + @tag = tag + @value = value super("uncaught throw #{tag.inspect}") end end - -module Kernel - def catch(tag=Object.new, &block) - block.call(tag) - rescue ThrowCatchJump => e - unless e._tag.equal?(tag) - raise e - end - return e._val - end - def throw(tag, val=nil) - raise ThrowCatchJump.new(tag, val) - end -end diff --git a/mrbgems/mruby-catch/src/catch.c b/mrbgems/mruby-catch/src/catch.c new file mode 100644 index 000000000..d910cac7f --- /dev/null +++ b/mrbgems/mruby-catch/src/catch.c @@ -0,0 +1,128 @@ +#include <mruby.h> +#include <mruby/class.h> +#include <mruby/variable.h> +#include <mruby/error.h> +#include <mruby/proc.h> +#include <mruby/opcode.h> +#include <mruby/presym.h> + + +MRB_PRESYM_DEFINE_VAR_AND_INITER(catch_syms_3, 1, MRB_SYM(call)) +static const mrb_code catch_iseq_3[18] = { + OP_ENTER, 0x00, 0x00, 0x00, + OP_GETUPVAR, 0x02, 0x02, 0x01, + OP_GETUPVAR, 0x03, 0x01, 0x01, + OP_SEND, 0x02, 0x00, 0x01, + OP_RETURN, 0x02,}; +static const mrb_irep catch_irep_3 = { + 2,5,0, + MRB_IREP_STATIC,catch_iseq_3, + NULL,catch_syms_3,NULL, + NULL, + NULL, + 18,0,1,0,0 +}; +static const mrb_irep *catch_reps_2[1] = { + &catch_irep_3, +}; +static const mrb_code catch_iseq_2[13] = { + OP_ENTER, 0x00, 0x00, 0x00, + OP_LAMBDA, 0x02, 0x00, + OP_SEND, 0x02, 0x00, 0x00, + OP_RETURN, 0x02,}; +static const mrb_irep catch_irep_2 = { + 2,4,0, + MRB_IREP_STATIC,catch_iseq_2, + NULL,catch_syms_3,catch_reps_2, + NULL, + NULL, + 13,0,1,1,0 +}; +static const mrb_irep *catch_reps_1[1] = { + &catch_irep_2, +}; +MRB_PRESYM_DEFINE_VAR_AND_INITER(catch_syms_1, 3, MRB_SYM(Object), MRB_SYM(new), MRB_SYM(call)) +static const mrb_code catch_iseq_1[29] = { + OP_ENTER, 0x00, 0x20, 0x01, + OP_JMP, 0x00, 0x03, + OP_JMP, 0x00, 0x0a, + OP_GETCONST, 0x03, 0x00, + OP_SEND, 0x03, 0x01, 0x00, + OP_MOVE, 0x01, 0x03, + OP_LAMBDA, 0x03, 0x00, + OP_SEND, 0x03, 0x02, 0x00, + OP_RETURN, 0x03,}; +static const mrb_irep catch_irep = { + 3,5,0, + MRB_IREP_STATIC,catch_iseq_1, + NULL,catch_syms_1,catch_reps_1, + NULL, + NULL, + 29,0,3,1,0 +}; + +#define ID_PRESERVED_CATCH MRB_SYM(__preserved_catch_proc) + +static const mrb_callinfo * +find_catcher(mrb_state *mrb, mrb_value tag) +{ + mrb_value pval = mrb_obj_iv_get(mrb, (struct RObject *)mrb->kernel_module, ID_PRESERVED_CATCH); + mrb_assert(mrb_proc_p(pval)); + const struct RProc *proc = mrb_proc_ptr(pval); + + const mrb_callinfo *ci = mrb->c->ci; + size_t n = ci - mrb->c->cibase; + ci--; + for (; n > 0; n--, ci--) { + const mrb_value *arg1 = ci->stack + 1; + if (ci->proc == proc && mrb_obj_eq(mrb, *arg1, tag)) { + return ci; + } + } + + return NULL; +} + +static mrb_value +mrb_f_throw(mrb_state *mrb, mrb_value self) +{ + mrb_value tag, obj; + if (mrb_get_args(mrb, "o|o", &tag, &obj) == 1) { + obj = mrb_nil_value(); + } + + const mrb_callinfo *ci = find_catcher(mrb, tag); + if (ci) { + struct RBreak *b = (struct RBreak *)mrb_obj_alloc(mrb, MRB_TT_BREAK, NULL); + mrb_break_value_set(b, obj); + mrb_break_proc_set(b, ci[2].proc); /* Back to the closure in `catch` method */ + mrb_exc_raise(mrb, mrb_obj_value(b)); + } + else { + mrb_value argv[2] = {tag, obj}; + mrb_exc_raise(mrb, mrb_obj_new(mrb, mrb_exc_get_id(mrb, MRB_ERROR_SYM(UncaughtThrowError)), 2, argv)); + } + /* not reached */ + return mrb_nil_value(); +} + +void +mrb_mruby_catch_gem_init(mrb_state *mrb) +{ + struct RProc *p; + mrb_method_t m; + + MRB_PRESYM_INIT_SYMBOLS(mrb, catch_syms_3); + MRB_PRESYM_INIT_SYMBOLS(mrb, catch_syms_1); + p = mrb_proc_new(mrb, &catch_irep); + MRB_METHOD_FROM_PROC(m, p); + mrb_define_method_raw(mrb, mrb->kernel_module, MRB_SYM(catch), m); + mrb_obj_iv_set(mrb, (struct RObject *)mrb->kernel_module, ID_PRESERVED_CATCH, mrb_obj_value(p)); + + mrb_define_method(mrb, mrb->kernel_module, "throw", mrb_f_throw, MRB_ARGS_ARG(1,1)); +} + +void +mrb_mruby_catch_gem_final(mrb_state *mrb) +{ +} diff --git a/mrbgems/mruby-catch/test/catch.rb b/mrbgems/mruby-catch/test/catch.rb index fe5bda096..38a4eb907 100644 --- a/mrbgems/mruby-catch/test/catch.rb +++ b/mrbgems/mruby-catch/test/catch.rb @@ -3,10 +3,14 @@ assert "return throw value" do result = catch :foo do loop do loop do - throw :foo, val + begin + throw :foo, val + rescue Exception + flunk("should not reach here 1") + end break end - flunk("should not reach here") + flunk("should not reach here 2") end false end @@ -30,13 +34,16 @@ assert "pass the given tag to block" do catch(tag){|t| assert_same(tag, t)} end -assert "tag identity" do - assert_raise_with_message_pattern(Exception, "uncaught throw *") do - catch [:tag] do - throw [:tag] - end - flunk("should not reach here") +assert "tag identity, uncaught throw" do + tag, val = [:tag], [:val] + catch [:tag] do + throw tag, val end + flunk("should not reach here") +rescue Exception => e + assert_match("uncaught throw *", e.message) + assert_same(tag, e.tag) + assert_same(val, e.value) end assert "without catch arguments" do diff --git a/mrbgems/mruby-cmath/mrbgem.rake b/mrbgems/mruby-cmath/mrbgem.rake index e00725fef..00ac4b091 100644 --- a/mrbgems/mruby-cmath/mrbgem.rake +++ b/mrbgems/mruby-cmath/mrbgem.rake @@ -1,5 +1,5 @@ # This `mruby-cmath` gem uses C99 _Complex features -# You need C compler that support C99+ +# You need C compiler that support C99+ MRuby::Gem::Specification.new('mruby-cmath') do |spec| spec.license = 'MIT' spec.author = 'mruby developers' diff --git a/mrbgems/mruby-cmath/src/cmath.c b/mrbgems/mruby-cmath/src/cmath.c index 857b58d26..03b181840 100644 --- a/mrbgems/mruby-cmath/src/cmath.c +++ b/mrbgems/mruby-cmath/src/cmath.c @@ -6,7 +6,7 @@ /* ** This `mruby-cmath` gem uses C99 _Complex features -** You need C compler that support C99+ +** You need C compiler that support C99+ */ #include <mruby.h> @@ -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-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 1a97b3ec6..1a07cc14b 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1450,7 +1450,7 @@ heredoc_end(parser_state *p) %token <nd> tSTRING tSTRING_PART tSTRING_MID %token <nd> tNTH_REF tBACK_REF %token <num> tREGEXP_END -%token <num> tNUMPARAM "numbered paraemeter" +%token <num> tNUMPARAM "numbered parameter" %type <nd> singleton string string_fragment string_rep string_interp xstring regexp %type <nd> literal numeric cpath symbol defn_head defs_head @@ -4682,6 +4682,7 @@ heredoc_remove_indent(parser_state *p, parser_heredoc_info *hinf) start = 0; while (start < len) { end = escaped ? (size_t)escaped->car : len; + if (end > len) end = len; spaces = (size_t)nspaces->car; size_t esclen = end - start; heredoc_count_indent(hinf, str + start, esclen, spaces, &offset); diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index 6c7940a7b..3e5c6e116 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -16,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program. If not, see <https://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -2085,7 +2085,7 @@ static const char *const yytname[] = "\"constant\"", "\"class variable\"", "\"label\"", "\"integer literal\"", "\"float literal\"", "\"character literal\"", "tXSTRING", "tREGEXP", "tSTRING", "tSTRING_PART", "tSTRING_MID", "tNTH_REF", "tBACK_REF", - "tREGEXP_END", "\"numbered paraemeter\"", "\"unary plus\"", + "tREGEXP_END", "\"numbered parameter\"", "\"unary plus\"", "\"unary minus\"", "\"<=>\"", "\"==\"", "\"===\"", "\"!=\"", "\">=\"", "\"<=\"", "\"&&\"", "\"||\"", "\"=~\"", "\"!~\"", "\"..\"", "\"...\"", "tBDOT2", "tBDOT3", "tAREF", "tASET", "\"<<\"", "\">>\"", "\"::\"", @@ -10718,6 +10718,7 @@ heredoc_remove_indent(parser_state *p, parser_heredoc_info *hinf) start = 0; while (start < len) { end = escaped ? (size_t)escaped->car : len; + if (end > len) end = len; spaces = (size_t)nspaces->car; size_t esclen = end - start; heredoc_count_indent(hinf, str + start, esclen, spaces, &offset); diff --git a/mrbgems/mruby-hash-ext/src/hash-ext.c b/mrbgems/mruby-hash-ext/src/hash-ext.c index 6345420ed..9c85858fe 100644 --- a/mrbgems/mruby-hash-ext/src/hash-ext.c +++ b/mrbgems/mruby-hash-ext/src/hash-ext.c @@ -74,7 +74,7 @@ hash_slice(mrb_state *mrb, mrb_value hash) * hsh.except(*keys) -> a_hash * * Returns a hash excluding the given keys and their values. - * + * * h = { a: 100, b: 200, c: 300 } * h.except(:a) #=> {:b=>200, :c=>300} * h.except(:b, :c, :d) #=> {:a=>100} 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-sleep/src/mrb_sleep.c b/mrbgems/mruby-sleep/src/sleep.c index 79a5af650..79a5af650 100644 --- a/mrbgems/mruby-sleep/src/mrb_sleep.c +++ b/mrbgems/mruby-sleep/src/sleep.c 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-struct/mrblib/struct.rb b/mrbgems/mruby-struct/mrblib/struct.rb index b398409c3..2439e2a37 100644 --- a/mrbgems/mruby-struct/mrblib/struct.rb +++ b/mrbgems/mruby-struct/mrblib/struct.rb @@ -2,99 +2,96 @@ # Struct # # ISO 15.2.18 +class Struct -if Object.const_defined?(:Struct) - class Struct + ## + # Calls the given block for each element of +self+ + # and pass the respective element. + # + # ISO 15.2.18.4.4 + def each(&block) + self.class.members.each{|field| + block.call(self[field]) + } + self + end - ## - # Calls the given block for each element of +self+ - # and pass the respective element. - # - # ISO 15.2.18.4.4 - def each(&block) - self.class.members.each{|field| - block.call(self[field]) - } - self - end + ## + # Calls the given block for each element of +self+ + # and pass the name and value of the respective + # element. + # + # ISO 15.2.18.4.5 + def each_pair(&block) + self.class.members.each{|field| + block.call(field.to_sym, self[field]) + } + self + end - ## - # Calls the given block for each element of +self+ - # and pass the name and value of the respective - # element. - # - # ISO 15.2.18.4.5 - def each_pair(&block) - self.class.members.each{|field| - block.call(field.to_sym, self[field]) - } - self - end + ## + # Calls the given block for each element of +self+ + # and returns an array with all elements of which + # block is not false. + # + # ISO 15.2.18.4.7 + def select(&block) + ary = [] + self.class.members.each{|field| + val = self[field] + ary.push(val) if block.call(val) + } + ary + end - ## - # Calls the given block for each element of +self+ - # and returns an array with all elements of which - # block is not false. - # - # ISO 15.2.18.4.7 - def select(&block) - ary = [] - self.class.members.each{|field| - val = self[field] - ary.push(val) if block.call(val) - } - ary + def _inspect(recur_list) + return "#<struct #{self.class}:...>" if recur_list[self.object_id] + recur_list[self.object_id] = true + name = self.class.to_s + if name[0] == "#" + str = "#<struct " + else + str = "#<struct #{name} " end - - def _inspect(recur_list) - return "#<struct #{self.class}:...>" if recur_list[self.object_id] - recur_list[self.object_id] = true - name = self.class.to_s - if name[0] == "#" - str = "#<struct " - else - str = "#<struct #{name} " - end - buf = [] - self.each_pair do |k,v| - buf.push k.to_s + "=" + v._inspect(recur_list) - end - str + buf.join(", ") + ">" + buf = [] + self.each_pair do |k,v| + buf.push k.to_s + "=" + v._inspect(recur_list) end + str + buf.join(", ") + ">" + end - ## - # call-seq: - # struct.to_s -> string - # struct.inspect -> string - # - # Describe the contents of this struct in a string. - # - # 15.2.18.4.10(x) - # - def inspect - self._inspect({}) - end + ## + # call-seq: + # struct.to_s -> string + # struct.inspect -> string + # + # Describe the contents of this struct in a string. + # + # 15.2.18.4.10(x) + # + def inspect + self._inspect({}) + end - ## - # 15.2.18.4.11(x) - # - alias to_s inspect + ## + # 15.2.18.4.11(x) + # + alias to_s inspect - ## - # call-seq: - # hsh.dig(key,...) -> object - # - # Extracts the nested value specified by the sequence of <i>key</i> - # objects by calling +dig+ at each step, returning +nil+ if any - # intermediate step is +nil+. - # - def dig(idx,*args) - n = self[idx] - if args.size > 0 - n&.dig(*args) - else - n - end + ## + # call-seq: + # hsh.dig(key,...) -> object + # + # Extracts the nested value specified by the sequence of <i>key</i> + # objects by calling +dig+ at each step, returning +nil+ if any + # intermediate step is +nil+. + # + def dig(idx,*args) + n = self[idx] + if args.size > 0 + n&.dig(*args) + else + n end end 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 diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake index 421108e0b..927447b4f 100644 --- a/mrbgems/mruby-test/mrbgem.rake +++ b/mrbgems/mruby-test/mrbgem.rake @@ -20,7 +20,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| _pp "GEN", t.name.relative_path mkdir_p File.dirname(t.name) open(t.name, 'w') do |f| - mrbc.run f, assert_rb, 'mrbtest_assert_irep', false + mrbc.run f, assert_rb, 'mrbtest_assert_irep', cdump: false end end @@ -52,10 +52,10 @@ MRuby::Gem::Specification.new('mruby-test') do |spec| if test_preload.nil? f.puts %Q[extern const uint8_t mrbtest_assert_irep[];] else - g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", false + g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", cdump: false end g.test_rbfiles.flatten.each_with_index do |rbfile, i| - g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", false + g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", cdump: false, static: true end f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] if g.custom_test_init? dep_list.each do |d| |
