diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-30 14:58:47 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-30 14:58:47 +0000 |
commit | e46471e90c656b6a4c0e6c6846040e51448c2255 (patch) | |
tree | 159502b64b891de8f284991fbfc8043e880e4943 | |
parent | 05ba90697f6a717b18bb9111960e157e8e9182eb (diff) | |
download | ruby-e46471e90c656b6a4c0e6c6846040e51448c2255.tar.gz |
* eval.c (rb_mod_refine): fix the error message when no block is
given. [ruby-dev:46319] [Bug #7244]
* test/ruby/test_refinement.rb: related test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | eval.c | 3 | ||||
-rw-r--r-- | test/ruby/test_refinement.rb | 10 |
3 files changed, 20 insertions, 0 deletions
@@ -1,3 +1,10 @@ +Tue Oct 30 23:59:32 2012 Shugo Maeda <shugo@ruby-lang.org> + + * eval.c (rb_mod_refine): fix the error message when no block is + given. [ruby-dev:46319] [Bug #7244] + + * test/ruby/test_refinement.rb: related test. + Tue Oct 30 19:27:48 2012 NAKAMURA Usaku <usa@ruby-lang.org> * process.c (redirect_dup2): set standard handles when new fd is stdio, @@ -1203,6 +1203,9 @@ rb_mod_refine(VALUE module, VALUE klass) ID id_refinements, id_refined_class; VALUE refinements; + if (!rb_block_given_p()) { + rb_raise(rb_eArgError, "no block given"); + } check_class_or_module(klass); CONST_ID(id_refinements, "__refinements__"); refinements = rb_attr_get(module, id_refinements); diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 6a1a1ccf80..fe1e23b656 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -520,4 +520,14 @@ class TestRefinement < Test::Unit::TestCase } assert_equal({c2 => c2_ext}, m2.refinements) end + + def test_refine_without_block + c1 = Class.new + e = assert_raise(ArgumentError) { + Module.new do + refine c1 + end + } + assert_equal("no block given", e.message) + end end |