diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-22 10:40:25 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-02-22 10:49:59 +0900 |
commit | 5b29ea0845c14092abd866ce0183c52635bade4c (patch) | |
tree | 1c01654c72d24c7fa499bb5b6f91fc3e55d6c84a /test/ruby/test_symbol.rb | |
parent | 31748e69c84894ac8f042a67d1320db8593c9ce1 (diff) | |
download | ruby-5b29ea0845c14092abd866ce0183c52635bade4c.tar.gz |
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/test_symbol.rb')
-rw-r--r-- | test/ruby/test_symbol.rb | 12 |
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 |