diff options
-rw-r--r-- | eval.c | 1 | ||||
-rw-r--r-- | test/ruby/test_refinement.rb | 21 |
2 files changed, 22 insertions, 0 deletions
@@ -1482,6 +1482,7 @@ static void ignored_block(VALUE module, const char *klass) { const char *anon = ""; + Check_Type(module, T_MODULE); if (!RTEST(rb_search_class_path(module))) { anon = ", maybe for Module.new"; } diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 31925f3933..629fcb894b 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1961,6 +1961,27 @@ class TestRefinement < Test::Unit::TestCase end end + def test_using_wrong_argument + bug = '[ruby-dev:50270] [Bug #13956]' + pattern = /expected Module/ + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = ""#{bug.dump} + pattern = /#{pattern}/ + begin; + assert_raise_with_message(TypeError, pattern, bug) { + using(1) do end + } + end; + assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}") + bug = ""#{bug.dump} + pattern = /#{pattern}/ + begin; + assert_raise_with_message(TypeError, pattern, bug) { + Module.new {using(1) {}} + } + end; + end + class ToString c = self using Module.new {refine(c) {def to_s; "ok"; end}} |