diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-24 06:42:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-10-24 06:42:22 +0000 |
commit | e0ed0012cb5752ff39eebd245aabba5d95bce986 (patch) | |
tree | 7f1e359b3a919e7bdbe57f8d1872d3cd4e92a853 /test/ruby/test_arity.rb | |
parent | 927e18b3701662975182d1c0caeb9477af70817e (diff) | |
download | ruby-e0ed0012cb5752ff39eebd245aabba5d95bce986.tar.gz |
relax error message format
* bootstraptest/test_method.rb: relax error message format.
* test/ruby/test_arity.rb (err_mess): ditto.
[Feature #9025], [ruby-core:71178] [Bug #11617]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_arity.rb')
-rw-r--r-- | test/ruby/test_arity.rb | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/test/ruby/test_arity.rb b/test/ruby/test_arity.rb index e026841749..4a24bdc660 100644 --- a/test/ruby/test_arity.rb +++ b/test/ruby/test_arity.rb @@ -3,7 +3,7 @@ require 'test/unit' class TestArity < Test::Unit::TestCase def err_mess(method_proc = nil, argc = 0) args = (1..argc).to_a - assert_raise_with_message(ArgumentError, /wrong number of arguments \((.*)\)/) do + assert_raise_with_message(ArgumentError, /wrong number of arguments \(.*\b(\d+)\b.* (\d\S*?)\)/) do case method_proc when nil yield @@ -13,7 +13,7 @@ class TestArity < Test::Unit::TestCase method_proc.call(*args) end end - $1 + [$1, $2] end def a @@ -35,22 +35,22 @@ class TestArity < Test::Unit::TestCase end def test_method_err_mess - assert_equal "1 for 0", err_mess(:a, 1) - assert_equal "10 for 7..9", err_mess(:b, 10) - assert_equal "2 for 3+", err_mess(:c, 2) - assert_equal "2 for 1", err_mess(:d, 2) - assert_equal "0 for 1", err_mess(:d, 0) - assert_equal "2 for 1", err_mess(:e, 2) - assert_equal "0 for 1", err_mess(:e, 0) - assert_equal "1 for 2+", err_mess(:f, 1) + assert_equal %w[1 0], err_mess(:a, 1) + assert_equal %w[10 7..9], err_mess(:b, 10) + assert_equal %w[2 3+], err_mess(:c, 2) + assert_equal %w[2 1], err_mess(:d, 2) + assert_equal %w[0 1], err_mess(:d, 0) + assert_equal %w[2 1], err_mess(:e, 2) + assert_equal %w[0 1], err_mess(:e, 0) + assert_equal %w[1 2+], err_mess(:f, 1) end def test_proc_err_mess - assert_equal "0 for 1..2", err_mess(->(b, c=42){}, 0) - assert_equal "1 for 2+", err_mess(->(a, b, c=42, *d){}, 1) - assert_equal "3 for 4+", err_mess(->(a, b, *c, d, e){}, 3) - assert_equal "3 for 1..2", err_mess(->(b, c=42){}, 3) - assert_equal "1 for 0", err_mess(->(&block){}, 1) + assert_equal %w[0 1..2], err_mess(->(b, c=42){}, 0) + assert_equal %w[1 2+], err_mess(->(a, b, c=42, *d){}, 1) + assert_equal %w[3 4+], err_mess(->(a, b, *c, d, e){}, 3) + assert_equal %w[3 1..2], err_mess(->(b, c=42){}, 3) + assert_equal %w[1 0], err_mess(->(&block){}, 1) # Double checking: p = Proc.new{|b, c=42| :ok} assert_equal :ok, p.call(1, 2, 3) @@ -58,12 +58,12 @@ class TestArity < Test::Unit::TestCase end def test_message_change_issue_6085 - assert_equal "3 for 1..2", err_mess{ SignalException.new(1, "", nil) } - assert_equal "1 for 0", err_mess{ Hash.new(1){} } - assert_equal "3 for 1..2", err_mess{ Module.send :define_method, 1, 2, 3 } - assert_equal "1 for 2", err_mess{ "".sub!(//) } - assert_equal "0 for 1..2", err_mess{ "".sub!{} } - assert_equal "0 for 1+", err_mess{ exec } - assert_equal "0 for 1+", err_mess{ Struct.new } + assert_equal %w[3 1..2], err_mess{ SignalException.new(1, "", nil) } + assert_equal %w[1 0], err_mess{ Hash.new(1){} } + assert_equal %w[3 1..2], err_mess{ Module.send :define_method, 1, 2, 3 } + assert_equal %w[1 2], err_mess{ "".sub!(//) } + assert_equal %w[0 1..2], err_mess{ "".sub!{} } + assert_equal %w[0 1+], err_mess{ exec } + assert_equal %w[0 1+], err_mess{ Struct.new } end end |