mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge branch 'master' into string-gsub
This commit is contained in:
@@ -34,6 +34,8 @@ class String
|
||||
m
|
||||
when "'"
|
||||
post
|
||||
when "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||
""
|
||||
else
|
||||
self[j, 2]
|
||||
end
|
||||
|
||||
+8
-2
@@ -330,8 +330,14 @@ mrb_class_get(mrb_state *mrb, const char *name)
|
||||
MRB_API struct RClass *
|
||||
mrb_exc_get(mrb_state *mrb, const char *name)
|
||||
{
|
||||
struct RClass *exc = mrb_class_get_under(mrb, mrb->object_class, name);
|
||||
struct RClass *e = exc;
|
||||
struct RClass *exc, *e;
|
||||
mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class),
|
||||
mrb_intern_cstr(mrb, name));
|
||||
|
||||
if (mrb_type(c) != MRB_TT_CLASS) {
|
||||
mrb_raise(mrb, mrb->eException_class, "exception corrupted");
|
||||
}
|
||||
exc = e = mrb_class_ptr(c);
|
||||
|
||||
while (e) {
|
||||
if (e == mrb->eException_class)
|
||||
|
||||
@@ -569,6 +569,7 @@ eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)
|
||||
p = mrb_proc_ptr(blk);
|
||||
ci->proc = p;
|
||||
ci->argc = 1;
|
||||
ci->mid = ci[-1].mid;
|
||||
if (MRB_PROC_CFUNC_P(p)) {
|
||||
stack_extend(mrb, 3, 0);
|
||||
mrb->c->stack[0] = self;
|
||||
@@ -1345,7 +1346,7 @@ RETRY_TRY_BLOCK:
|
||||
int a = GETARG_A(i);
|
||||
int n = GETARG_C(i);
|
||||
|
||||
if (mid == 0 || !mrb->c->ci->target_class) {
|
||||
if (mid == 0 || !ci->target_class) {
|
||||
mrb_value exc;
|
||||
|
||||
exc = mrb_exc_new_str_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
|
||||
|
||||
@@ -365,6 +365,7 @@ assert('String#gsub', '15.2.10.5.18') do
|
||||
assert_equal('$$a$$', '##a##'.gsub('##'){|w| '$$' }, 'mruby/mruby#847 another case with block')
|
||||
assert_equal('A', 'a'.gsub('a', 'A'))
|
||||
assert_equal('A', 'a'.gsub('a'){|w| w.capitalize })
|
||||
assert_equal("<a><><>", 'a'.gsub('a', '<\0><\1><\2>'))
|
||||
assert_equal(".h.e.l.l.o.", "hello".gsub("", "."))
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user