summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--eval.c3
-rw-r--r--test/ruby/test_refinement.rb10
3 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8890e66f413..40dba2f7556 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
diff --git a/eval.c b/eval.c
index 6bac9ca7c7e..c1d22d66fad 100644
--- a/eval.c
+++ b/eval.c
@@ -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 6a1a1ccf807..fe1e23b656d 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