mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
include and prepend check no args
* eval.c (rb_mod_include, rb_mod_prepend): check if arguments are given, as well as Kernel#extend. [ruby-dev:49854] [Bug #12887] [Fix GH-1470] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2456f869c8
commit
d2101310db
3 changed files with 21 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Nov 6 14:42:50 2016 takkanm <takkanm@gmail.com>
|
||||
|
||||
* eval.c (rb_mod_include, rb_mod_prepend): check if arguments are
|
||||
given, as well as Kernel#extend. [ruby-dev:49854] [Bug #12887]
|
||||
[Fix GH-1470]
|
||||
|
||||
Sun Nov 6 11:59:05 2016 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* test/rinda/test_rinda.rb (test_make_socket_ipv6_multicast,
|
||||
|
|
3
eval.c
3
eval.c
|
@ -1036,6 +1036,7 @@ rb_mod_include(int argc, VALUE *argv, VALUE module)
|
|||
CONST_ID(id_append_features, "append_features");
|
||||
CONST_ID(id_included, "included");
|
||||
|
||||
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||
for (i = 0; i < argc; i++)
|
||||
Check_Type(argv[i], T_MODULE);
|
||||
while (argc--) {
|
||||
|
@ -1083,6 +1084,8 @@ rb_mod_prepend(int argc, VALUE *argv, VALUE module)
|
|||
|
||||
CONST_ID(id_prepend_features, "prepend_features");
|
||||
CONST_ID(id_prepended, "prepended");
|
||||
|
||||
rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
|
||||
for (i = 0; i < argc; i++)
|
||||
Check_Type(argv[i], T_MODULE);
|
||||
while (argc--) {
|
||||
|
|
|
@ -440,6 +440,10 @@ class TestModule < Test::Unit::TestCase
|
|||
EOS
|
||||
end
|
||||
|
||||
def test_include_with_no_args
|
||||
assert_raise(ArgumentError) { Module.new { include } }
|
||||
end
|
||||
|
||||
def test_included_modules
|
||||
assert_equal([], Mixin.included_modules)
|
||||
assert_equal([Mixin], User.included_modules)
|
||||
|
@ -1868,6 +1872,10 @@ class TestModule < Test::Unit::TestCase
|
|||
end;
|
||||
end
|
||||
|
||||
def test_prepend_module_with_no_args
|
||||
assert_raise(ArgumentError) { Module.new { prepend } }
|
||||
end
|
||||
|
||||
def test_class_variables
|
||||
m = Module.new
|
||||
m.class_variable_set(:@@foo, 1)
|
||||
|
@ -1934,6 +1942,10 @@ class TestModule < Test::Unit::TestCase
|
|||
assert_equal(['public', 'protected'], list)
|
||||
end
|
||||
|
||||
def test_extend_module_with_no_args
|
||||
assert_raise(ArgumentError) { Module.new { extend } }
|
||||
end
|
||||
|
||||
def test_invalid_attr
|
||||
%W[
|
||||
foo?
|
||||
|
|
Loading…
Add table
Reference in a new issue