summaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 04:35:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 04:35:58 +0000
commit6ddeecce9c090447f76c99e111237115f6cc2f33 (patch)
tree1a274ad80a96f2546c0aba4701fd0c0e78857b5b /test/ruby
parent18c20cccee7d912bfe963a901a6cdb41f3db07e1 (diff)
downloadruby-6ddeecce9c090447f76c99e111237115f6cc2f33.tar.gz
ruby-6ddeecce9c090447f76c99e111237115f6cc2f33.tar.xz
ruby-6ddeecce9c090447f76c99e111237115f6cc2f33.zip
* yarvcore.h, compile.c (set_arguments): support post arguments.
* test/ruby/test_method.rb: add tests for above. * test/ruby/test_proc.rb: ditto. * proc.c: fix an arity bug ([ruby-core:11029]). * vm.c, vm.h, insns.def, vm_dump.h: fix bmethod process. * vm.c: support block argument on block parameter. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_method.rb4
-rw-r--r--test/ruby/test_proc.rb8
2 files changed, 9 insertions, 3 deletions
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index c30705cb1..5f436406a 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -8,6 +8,8 @@ class TestMethod < Test::Unit::TestCase
def mo2(a, b = nil) end
def mo3(*a) end
def mo4(a, *b, &c) end
+ def mo5(a, *b, c) end
+ def mo6(a, *b, c, &d) end
class Base
def foo() :base end
@@ -24,6 +26,8 @@ class TestMethod < Test::Unit::TestCase
assert_equal(-2, method(:mo2).arity)
assert_equal(-1, method(:mo3).arity)
assert_equal(-2, method(:mo4).arity)
+ assert_equal(-3, method(:mo5).arity)
+ assert_equal(-3, method(:mo6).arity)
end
def test_unbind
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index f293bbc1a..49e9d9284 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -57,12 +57,15 @@ class TestProc < Test::Unit::TestCase
assert_equal(-2, proc{|x, *y|}.arity)
assert_equal(-1, proc{|*x|}.arity)
assert_equal(-1, proc{|*|}.arity)
+ assert_equal(-3, proc{|x, *y, z|}.arity)
+ assert_equal(-4, proc{|x, *y, z, a|}.arity)
assert_arity(0) {}
assert_arity(0) {||}
assert_arity(1) {|x|}
assert_arity(2) {|x, y|}
assert_arity(-2) {|x, *y|}
+ assert_arity(-3) {|x, *y, z|}
assert_arity(-1) {|*x|}
assert_arity(-1) {|*|}
end
@@ -89,9 +92,8 @@ class TestProc < Test::Unit::TestCase
end
def test_block_par
- assert false, "TODO: block parameter |&b| not supported"
- # assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
- # assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
+ assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x})
+ assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x})
end
def test_safe