Merge branch 'master' of http://github.com/mruby/mruby into alloc_doc

This commit is contained in:
Jared Breeden
2015-06-22 23:20:24 -07:00
8 changed files with 26 additions and 6 deletions
+3
View File
@@ -70,4 +70,7 @@ MRuby::GemBox.new do |conf|
# Use extensional Kernel module
conf.gem :core => "mruby-kernel-ext"
# Use mruby-compiler to build other mrbgems
conf.gem :core => "mruby-compiler"
end
+1
View File
@@ -26,4 +26,5 @@ MRuby::Gem::Specification.new('mruby-bin-mirb') do |spec|
end
spec.bins = %w(mirb)
spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
end
+1
View File
@@ -3,4 +3,5 @@ MRuby::Gem::Specification.new('mruby-bin-mruby') do |spec|
spec.author = 'mruby developers'
spec.summary = 'mruby command'
spec.bins = %w(mruby)
spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
end
+3 -1
View File
@@ -13,9 +13,11 @@ class Proc
end
def curry(arity=self.arity)
type = :proc
abs = lambda {|a| a < 0 ? -a - 1 : a}
arity = abs[arity]
if lambda?
type = :lambda
self_arity = self.arity
if (self_arity >= 0 && arity != self_arity) ||
(self_arity < 0 && abs[self_arity] > arity)
@@ -25,7 +27,7 @@ class Proc
pproc = self
make_curry = proc do |given_args=[]|
proc do |*args|
send(type) do |*args|
new_args = given_args + args
if new_args.size >= arity
pproc[*new_args]
+3
View File
@@ -41,6 +41,9 @@ assert('Proc#curry') do
assert_raise(ArgumentError) { b.curry[1, 2][3, 4] }
assert_raise(ArgumentError) { b.curry(5) }
assert_raise(ArgumentError) { b.curry(1) }
assert_false(proc{}.curry.lambda?)
assert_true(lambda{}.curry.lambda?)
end
assert('Proc#parameters') do
+3 -2
View File
@@ -200,7 +200,7 @@ mrb_proc_arity(mrb_state *mrb, mrb_value self)
struct RProc *p = mrb_proc_ptr(self);
mrb_code *iseq = mrb_proc_iseq(mrb, p);
mrb_aspec aspec;
int ma, ra, pa, arity;
int ma, op, ra, pa, arity;
if (MRB_PROC_CFUNC_P(p)) {
/* TODO cfunc aspec not implemented yet */
@@ -214,9 +214,10 @@ mrb_proc_arity(mrb_state *mrb, mrb_value self)
aspec = GETARG_Ax(*iseq);
ma = MRB_ASPEC_REQ(aspec);
op = MRB_ASPEC_OPT(aspec);
ra = MRB_ASPEC_REST(aspec);
pa = MRB_ASPEC_POST(aspec);
arity = ra ? -(ma + pa + 1) : ma + pa;
arity = ra || (MRB_PROC_STRICT_P(p) && op) ? -(ma + pa + 1) : ma + pa;
return mrb_fixnum_value(arity);
}
+4 -3
View File
@@ -1985,7 +1985,8 @@ bad:
MRB_API const char*
mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr)
{
struct RString *ps = mrb_str_ptr(*ptr);
mrb_value str = mrb_str_to_str(mrb, *ptr);
struct RString *ps = mrb_str_ptr(str);
mrb_int len = mrb_str_strlen(mrb, ps);
char *p = RSTR_PTR(ps);
@@ -2002,12 +2003,12 @@ mrb_str_to_inum(mrb_state *mrb, mrb_value str, mrb_int base, mrb_bool badcheck)
const char *s;
mrb_int len;
str = mrb_str_to_str(mrb, str);
if (badcheck) {
/* Raises if the string contains a null character (the badcheck) */
s = mrb_string_value_cstr(mrb, &str);
}
else {
s = RSTRING_PTR(str);
s = mrb_string_value_ptr(mrb, str);
}
if (s) {
len = RSTRING_LEN(str);
+8
View File
@@ -36,6 +36,14 @@ assert('Proc#arity', '15.2.17.4.2') do
assert_equal(-3, b)
assert_equal 1, c
assert_equal 1, d
e = ->(x=0, y){}.arity
f = ->((x, y), z=0){}.arity
g = ->(x=0){}.arity
assert_equal(-2, e)
assert_equal(-2, f)
assert_equal(-1, g)
end
assert('Proc#call', '15.2.17.4.3') do