mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (top_using): remove Kernel#using, and add main.using instead.
* test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b0c8aeeb9c
commit
10ba3bdd53
3 changed files with 34 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Nov 11 15:12:18 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* eval.c (top_using): remove Kernel#using, and add main.using instead.
|
||||
|
||||
* test/ruby/test_refinement.rb: related test.
|
||||
|
||||
Sun Nov 11 13:41:01 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_using_refinement, rb_mod_using, f_using): clear method
|
||||
|
|
5
eval.c
5
eval.c
|
@ -1386,7 +1386,7 @@ top_include(int argc, VALUE *argv, VALUE self)
|
|||
*/
|
||||
|
||||
static VALUE
|
||||
f_using(VALUE self, VALUE module)
|
||||
top_using(VALUE self, VALUE module)
|
||||
{
|
||||
NODE *cref = rb_vm_cref();
|
||||
|
||||
|
@ -1593,8 +1593,7 @@ Init_eval(void)
|
|||
rb_define_singleton_method(rb_cModule, "constants", rb_mod_s_constants, -1);
|
||||
|
||||
rb_define_singleton_method(rb_vm_top_self(), "include", top_include, -1);
|
||||
|
||||
rb_define_global_function("using", f_using, 1);
|
||||
rb_define_singleton_method(rb_vm_top_self(), "using", top_using, 1);
|
||||
|
||||
rb_define_method(rb_mKernel, "extend", rb_obj_extend, -1);
|
||||
|
||||
|
|
|
@ -474,10 +474,32 @@ class TestRefinement < Test::Unit::TestCase
|
|||
assert_equal("c", c.class_eval { 123.foo })
|
||||
end
|
||||
|
||||
def test_kernel_using_class
|
||||
c = Class.new
|
||||
assert_raise(TypeError) do
|
||||
using c
|
||||
def test_main_using
|
||||
assert_in_out_err([], <<-INPUT, %w(:C :M), [])
|
||||
class C
|
||||
def foo
|
||||
:C
|
||||
end
|
||||
end
|
||||
|
||||
module M
|
||||
refine C do
|
||||
def foo
|
||||
:M
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
c = C.new
|
||||
p c.foo
|
||||
using M
|
||||
p c.foo
|
||||
INPUT
|
||||
end
|
||||
|
||||
def test_no_kernel_using
|
||||
assert_raise(NoMethodError) do
|
||||
using Module.new
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue