summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-22 10:40:25 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-02-22 10:49:59 +0900
commit5b29ea0845c14092abd866ce0183c52635bade4c (patch)
tree1c01654c72d24c7fa499bb5b6f91fc3e55d6c84a /test/ruby
parent31748e69c84894ac8f042a67d1320db8593c9ce1 (diff)
Proc from Symbol needs a receiver
So its arity should be -2 instead of -1. [Bug #16640] https://bugs.ruby-lang.org/issues/16640#change-84337
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_symbol.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 632acb3e3d..569b888f31 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -157,6 +157,10 @@ class TestSymbol < Test::Unit::TestCase
assert_predicate(:itself.to_proc, :lambda?)
end
+ def test_to_proc_arity
+ assert_equal(-2, :itself.to_proc.arity)
+ end
+
def test_to_proc_call_with_symbol_proc
first = 1
bug11594 = "[ruby-core:71088] [Bug #11594] corrupted the first local variable"
@@ -187,6 +191,10 @@ class TestSymbol < Test::Unit::TestCase
assert_predicate(_test_to_proc_with_refinements_call(&:hoge), :lambda?)
end
+ def test_to_proc_arity_with_refinements
+ assert_equal(-2, _test_to_proc_with_refinements_call(&:hoge).arity)
+ end
+
def self._test_to_proc_arg_with_refinements_call(&block)
block.call TestToPRocArgWithRefinements.new
end
@@ -230,11 +238,11 @@ class TestSymbol < Test::Unit::TestCase
begin;
bug11845 = '[ruby-core:72381] [Bug #11845]'
assert_nil(:class.to_proc.source_location, bug11845)
- assert_equal([[:rest]], :class.to_proc.parameters, bug11845)
+ assert_equal([[:req], [:rest]], :class.to_proc.parameters, bug11845)
c = Class.new {define_method(:klass, :class.to_proc)}
m = c.instance_method(:klass)
assert_nil(m.source_location, bug11845)
- assert_equal([[:rest]], m.parameters, bug11845)
+ assert_equal([[:req], [:rest]], m.parameters, bug11845)
end;
end