summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-proc-ext
diff options
context:
space:
mode:
authorAsmod4n <[email protected]>2015-09-17 13:24:17 +0200
committerAsmod4n <[email protected]>2015-09-17 13:24:17 +0200
commite6d9b450bab46f218e6bee2c95114b733660951a (patch)
treee6e296d99ad3780e769a5bae0d71bb5a6de75c9a /mrbgems/mruby-proc-ext
parent13a2cc3e5d27c33db7f4cf06ece4c44a79c79c53 (diff)
parent070e04ea22d832c323e56ff75242f08ca3022fa8 (diff)
downloadmruby-e6d9b450bab46f218e6bee2c95114b733660951a.tar.gz
mruby-e6d9b450bab46f218e6bee2c95114b733660951a.zip
Merge remote-tracking branch 'mruby/master'
Diffstat (limited to 'mrbgems/mruby-proc-ext')
-rw-r--r--mrbgems/mruby-proc-ext/mrbgem.rake2
-rw-r--r--mrbgems/mruby-proc-ext/mrblib/proc.rb4
-rw-r--r--mrbgems/mruby-proc-ext/test/proc.rb3
3 files changed, 7 insertions, 2 deletions
diff --git a/mrbgems/mruby-proc-ext/mrbgem.rake b/mrbgems/mruby-proc-ext/mrbgem.rake
index 41d964bd9..e4d15a140 100644
--- a/mrbgems/mruby-proc-ext/mrbgem.rake
+++ b/mrbgems/mruby-proc-ext/mrbgem.rake
@@ -1,5 +1,5 @@
MRuby::Gem::Specification.new('mruby-proc-ext') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
- spec.summary = 'extensional Proc class'
+ spec.summary = 'Proc class extension'
end
diff --git a/mrbgems/mruby-proc-ext/mrblib/proc.rb b/mrbgems/mruby-proc-ext/mrblib/proc.rb
index 5dd9981df..b71663938 100644
--- a/mrbgems/mruby-proc-ext/mrblib/proc.rb
+++ b/mrbgems/mruby-proc-ext/mrblib/proc.rb
@@ -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]
diff --git a/mrbgems/mruby-proc-ext/test/proc.rb b/mrbgems/mruby-proc-ext/test/proc.rb
index bca9b463a..75e11dd93 100644
--- a/mrbgems/mruby-proc-ext/test/proc.rb
+++ b/mrbgems/mruby-proc-ext/test/proc.rb
@@ -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