* eval.c (rb_mod_s_used_modules): rename Module.used_refinements to
Module.used_modules. [Feature #7418] [ruby-core:49805] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dbff56f562
commit
5fac45dc30
@ -1,3 +1,8 @@
|
|||||||
|
Thu Sep 8 16:47:03 2016 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_mod_s_used_modules): rename Module.used_refinements to
|
||||||
|
Module.used_modules. [Feature #7418] [ruby-core:49805]
|
||||||
|
|
||||||
Thu Sep 8 14:21:48 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Thu Sep 8 14:21:48 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* ext/psych/psych.gemspec, lib/rdoc/rdoc.gemspec: Use file list instead of
|
* ext/psych/psych.gemspec, lib/rdoc/rdoc.gemspec: Use file list instead of
|
||||||
|
18
eval.c
18
eval.c
@ -1312,7 +1312,7 @@ mod_using(VALUE self, VALUE module)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
used_refinements_i(VALUE _, VALUE mod, VALUE ary)
|
used_modules_i(VALUE _, VALUE mod, VALUE ary)
|
||||||
{
|
{
|
||||||
ID id_defined_at;
|
ID id_defined_at;
|
||||||
CONST_ID(id_defined_at, "__defined_at__");
|
CONST_ID(id_defined_at, "__defined_at__");
|
||||||
@ -1325,10 +1325,10 @@ used_refinements_i(VALUE _, VALUE mod, VALUE ary)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* used_refinements -> array
|
* used_modules -> array
|
||||||
*
|
*
|
||||||
* Returns an array of all active refinements in the current scope. The
|
* Returns an array of all modules used in the current scope. The ordering
|
||||||
* ordering of modules in the resulting array is not defined.
|
* of modules in the resulting array is not defined.
|
||||||
*
|
*
|
||||||
* module A
|
* module A
|
||||||
* refine Object do
|
* refine Object do
|
||||||
@ -1342,21 +1342,21 @@ used_refinements_i(VALUE _, VALUE mod, VALUE ary)
|
|||||||
*
|
*
|
||||||
* using A
|
* using A
|
||||||
* using B
|
* using B
|
||||||
* p Module.used_refinements
|
* p Module.used_modules
|
||||||
*
|
*
|
||||||
* <em>produces:</em>
|
* <em>produces:</em>
|
||||||
*
|
*
|
||||||
* [B, A]
|
* [B, A]
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mod_s_used_refinements(void)
|
rb_mod_s_used_modules(void)
|
||||||
{
|
{
|
||||||
const rb_cref_t *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
VALUE ary = rb_ary_new();
|
VALUE ary = rb_ary_new();
|
||||||
|
|
||||||
while(cref) {
|
while(cref) {
|
||||||
if(!NIL_P(CREF_REFINEMENTS(cref))) {
|
if(!NIL_P(CREF_REFINEMENTS(cref))) {
|
||||||
rb_hash_foreach(CREF_REFINEMENTS(cref), used_refinements_i, ary);
|
rb_hash_foreach(CREF_REFINEMENTS(cref), used_modules_i, ary);
|
||||||
}
|
}
|
||||||
cref = CREF_NEXT(cref);
|
cref = CREF_NEXT(cref);
|
||||||
}
|
}
|
||||||
@ -1698,8 +1698,8 @@ Init_eval(void)
|
|||||||
rb_define_private_method(rb_cModule, "prepend_features", rb_mod_prepend_features, 1);
|
rb_define_private_method(rb_cModule, "prepend_features", rb_mod_prepend_features, 1);
|
||||||
rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
|
rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
|
||||||
rb_define_private_method(rb_cModule, "using", mod_using, 1);
|
rb_define_private_method(rb_cModule, "using", mod_using, 1);
|
||||||
rb_define_singleton_method(rb_cModule, "used_refinements",
|
rb_define_singleton_method(rb_cModule, "used_modules",
|
||||||
rb_mod_s_used_refinements, 0);
|
rb_mod_s_used_modules, 0);
|
||||||
rb_undef_method(rb_cClass, "refine");
|
rb_undef_method(rb_cClass, "refine");
|
||||||
|
|
||||||
rb_undef_method(rb_cClass, "module_function");
|
rb_undef_method(rb_cClass, "module_function");
|
||||||
|
@ -1651,27 +1651,27 @@ class TestRefinement < Test::Unit::TestCase
|
|||||||
|
|
||||||
module Foo
|
module Foo
|
||||||
using RefB
|
using RefB
|
||||||
USED_REFS = Module.used_refinements
|
USED_MODS = Module.used_modules
|
||||||
end
|
end
|
||||||
|
|
||||||
module Bar
|
module Bar
|
||||||
using RefC
|
using RefC
|
||||||
USED_REFS = Module.used_refinements
|
USED_MODS = Module.used_modules
|
||||||
end
|
end
|
||||||
|
|
||||||
module Combined
|
module Combined
|
||||||
using RefA
|
using RefA
|
||||||
using RefB
|
using RefB
|
||||||
USED_REFS = Module.used_refinements
|
USED_MODS = Module.used_modules
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_used_refinements
|
def test_used_modules
|
||||||
ref = VisibleRefinements
|
ref = VisibleRefinements
|
||||||
assert_equal [], Module.used_refinements
|
assert_equal [], Module.used_modules
|
||||||
assert_equal [ref::RefB], ref::Foo::USED_REFS
|
assert_equal [ref::RefB], ref::Foo::USED_MODS
|
||||||
assert_equal [ref::RefC], ref::Bar::USED_REFS
|
assert_equal [ref::RefC], ref::Bar::USED_MODS
|
||||||
assert_equal [ref::RefB, ref::RefA], ref::Combined::USED_REFS
|
assert_equal [ref::RefB, ref::RefA], ref::Combined::USED_MODS
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_warn_setconst_in_refinmenet
|
def test_warn_setconst_in_refinmenet
|
||||||
|
Loading…
x
Reference in New Issue
Block a user