[前][次][番号順一覧][スレッド一覧]

ruby-changes:31988

From: nobu <ko1@a...>
Date: Sun, 8 Dec 2013 16:17:23 +0900 (JST)
Subject: [ruby-changes:31988] nobu:r44067 (trunk): test_keyword.rb: check error messages

nobu	2013-12-08 16:17:18 +0900 (Sun, 08 Dec 2013)

  New Revision: 44067

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44067

  Log:
    test_keyword.rb: check error messages
    
    * test/ruby/test_keyword.rb (test_required_keyword): check also
      error messages.
    
    * test/ruby/test_keyword.rb (test_block_required_keyword): ditto.

  Modified files:
    trunk/test/ruby/test_keyword.rb
Index: test/ruby/test_keyword.rb
===================================================================
--- test/ruby/test_keyword.rb	(revision 44066)
+++ test/ruby/test_keyword.rb	(revision 44067)
@@ -305,15 +305,16 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L305
       eval("def o.foo(a:) a; end")
       eval("def o.bar(a:,**b) [a, b]; end")
     end
-    assert_raise(ArgumentError, feature7701) {o.foo}
+    assert_raise_with_message(ArgumentError, /missing keyword/, feature7701) {o.foo}
     assert_equal(42, o.foo(a: 42), feature7701)
     assert_equal([[:keyreq, :a]], o.method(:foo).parameters, feature7701)
 
     bug8139 = '[ruby-core:53608] [Bug #8139] required keyword argument with rest hash'
     assert_equal([42, {}], o.bar(a: 42), feature7701)
+    assert_equal([42, {c: feature7701}], o.bar(a: 42, c: feature7701), feature7701)
     assert_equal([[:keyreq, :a], [:keyrest, :b]], o.method(:bar).parameters, feature7701)
-    assert_raise(ArgumentError, bug8139) {o.bar(c: bug8139)}
-    assert_raise(ArgumentError, bug8139) {o.bar}
+    assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar(c: bug8139)}
+    assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {o.bar}
   end
 
   def test_block_required_keyword
@@ -321,7 +322,7 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L322
     b = assert_nothing_raised(SyntaxError, feature7701) do
       break eval("proc {|a:| a}")
     end
-    assert_raise(ArgumentError, feature7701) {b.call}
+    assert_raise_with_message(ArgumentError, /missing keyword/, feature7701) {b.call}
     assert_equal(42, b.call(a: 42), feature7701)
     assert_equal([[:keyreq, :a]], b.parameters, feature7701)
 
@@ -330,9 +331,10 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L331
       break eval("proc {|a:, **b| [a, b]}")
     end
     assert_equal([42, {}], b.call(a: 42), feature7701)
+    assert_equal([42, {c: feature7701}], b.call(a: 42, c: feature7701), feature7701)
     assert_equal([[:keyreq, :a], [:keyrest, :b]], b.parameters, feature7701)
-    assert_raise(ArgumentError, bug8139) {b.call(c: bug8139)}
-    assert_raise(ArgumentError, bug8139) {b.call}
+    assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {b.call(c: bug8139)}
+    assert_raise_with_message(ArgumentError, /missing keyword/, bug8139) {b.call}
   end
 
   def test_super_with_keyword

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]