mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
05ba90697f
commit
e46471e90c
3 changed files with 20 additions and 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>
|
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,
|
* process.c (redirect_dup2): set standard handles when new fd is stdio,
|
||||||
|
|
3
eval.c
3
eval.c
|
@ -1203,6 +1203,9 @@ rb_mod_refine(VALUE module, VALUE klass)
|
||||||
ID id_refinements, id_refined_class;
|
ID id_refinements, id_refined_class;
|
||||||
VALUE refinements;
|
VALUE refinements;
|
||||||
|
|
||||||
|
if (!rb_block_given_p()) {
|
||||||
|
rb_raise(rb_eArgError, "no block given");
|
||||||
|
}
|
||||||
check_class_or_module(klass);
|
check_class_or_module(klass);
|
||||||
CONST_ID(id_refinements, "__refinements__");
|
CONST_ID(id_refinements, "__refinements__");
|
||||||
refinements = rb_attr_get(module, id_refinements);
|
refinements = rb_attr_get(module, id_refinements);
|
||||||
|
|
|
@ -520,4 +520,14 @@ class TestRefinement < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
assert_equal({c2 => c2_ext}, m2.refinements)
|
assert_equal({c2 => c2_ext}, m2.refinements)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue