Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
b80e0ef7
Commit
b80e0ef7
authored
Sep 01, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `Kernel#send` to `mruby-metaprog` gem.
But `BasicObject#__send__` is still available from the core.
parent
593c12a5
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
89 deletions
+85
-89
mrbgems/mruby-eval/test/eval.rb
mrbgems/mruby-eval/test/eval.rb
+1
-1
mrbgems/mruby-metaprog/src/metaprog.c
mrbgems/mruby-metaprog/src/metaprog.c
+1
-0
mrbgems/mruby-metaprog/test/metaprog.rb
mrbgems/mruby-metaprog/test/metaprog.rb
+27
-0
mrbgems/mruby-method/test/method.rb
mrbgems/mruby-method/test/method.rb
+1
-4
src/kernel.c
src/kernel.c
+0
-1
test/t/codegen.rb
test/t/codegen.rb
+2
-2
test/t/kernel.rb
test/t/kernel.rb
+0
-28
test/t/module.rb
test/t/module.rb
+53
-53
No files found.
mrbgems/mruby-eval/test/eval.rb
View file @
b80e0ef7
...
@@ -34,7 +34,7 @@ assert('Kernel.eval', '15.3.1.2.3') do
...
@@ -34,7 +34,7 @@ assert('Kernel.eval', '15.3.1.2.3') do
}
}
assert_equal
(
2
)
{
assert_equal
(
2
)
{
a
=
10
a
=
10
Kernel
.
eval
'def f(a); b=a
.send(:+, 1)
; end'
Kernel
.
eval
'def f(a); b=a
+1
; end'
f
(
1
)
f
(
1
)
}
}
end
end
...
...
mrbgems/mruby-metaprog/src/metaprog.c
View file @
b80e0ef7
...
@@ -680,6 +680,7 @@ mrb_mruby_metaprog_gem_init(mrb_state* mrb)
...
@@ -680,6 +680,7 @@ mrb_mruby_metaprog_gem_init(mrb_state* mrb)
mrb_define_method
(
mrb
,
krn
,
"public_methods"
,
mrb_obj_public_methods
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.38 */
mrb_define_method
(
mrb
,
krn
,
"public_methods"
,
mrb_obj_public_methods
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.38 */
mrb_define_method
(
mrb
,
krn
,
"singleton_methods"
,
mrb_obj_singleton_methods_m
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.45 */
mrb_define_method
(
mrb
,
krn
,
"singleton_methods"
,
mrb_obj_singleton_methods_m
,
MRB_ARGS_OPT
(
1
));
/* 15.3.1.3.45 */
mrb_define_method
(
mrb
,
krn
,
"define_singleton_method"
,
mod_define_singleton_method
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
krn
,
"define_singleton_method"
,
mod_define_singleton_method
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
krn
,
"send"
,
mrb_f_send
,
MRB_ARGS_ANY
());
/* 15.3.1.3.44 */
mrb_define_method
(
mrb
,
mod
,
"class_variables"
,
mrb_mod_class_variables
,
MRB_ARGS_NONE
());
/* 15.2.2.4.19 */
mrb_define_method
(
mrb
,
mod
,
"class_variables"
,
mrb_mod_class_variables
,
MRB_ARGS_NONE
());
/* 15.2.2.4.19 */
mrb_define_method
(
mrb
,
mod
,
"remove_class_variable"
,
mrb_mod_remove_cvar
,
MRB_ARGS_REQ
(
1
));
/* 15.2.2.4.39 */
mrb_define_method
(
mrb
,
mod
,
"remove_class_variable"
,
mrb_mod_remove_cvar
,
MRB_ARGS_REQ
(
1
));
/* 15.2.2.4.39 */
...
...
mrbgems/mruby-metaprog/test/metaprog.rb
View file @
b80e0ef7
assert
(
'Kernel#__send__'
,
'15.3.1.3.4'
)
do
# test with block
l
=
__send__
(
:lambda
)
do
true
end
assert_true
l
.
call
assert_equal
Proc
,
l
.
class
# test with argument
assert_true
__send__
(
:respond_to?
,
:nil?
)
# test without argument and without block
assert_equal
String
,
__send__
(
:to_s
).
class
end
assert
(
'Kernel#send'
,
'15.3.1.3.44'
)
do
# test with block
l
=
send
(
:lambda
)
do
true
end
assert_true
l
.
call
assert_equal
l
.
class
,
Proc
# test with argument
assert_true
send
(
:respond_to?
,
:nil?
)
# test without argument and without block
assert_equal
send
(
:to_s
).
class
,
String
end
assert
(
'Kernel#instance_variable_defined?'
,
'15.3.1.3.20'
)
do
assert
(
'Kernel#instance_variable_defined?'
,
'15.3.1.3.20'
)
do
o
=
Object
.
new
o
=
Object
.
new
...
...
mrbgems/mruby-method/test/method.rb
View file @
b80e0ef7
...
@@ -102,10 +102,7 @@ end
...
@@ -102,10 +102,7 @@ end
assert
'Method#call for regression'
do
assert
'Method#call for regression'
do
obj
=
BasicObject
.
new
obj
=
BasicObject
.
new
def
obj
.
foo
assert_equal
String
,
Kernel
.
instance_method
(
:inspect
).
bind
(
obj
).
call
().
class
,
"https://github.com/ksss/mruby-method/issues/4"
:ok
end
assert_equal
:ok
,
Kernel
.
instance_method
(
:send
).
bind
(
obj
).
call
(
:foo
),
"https://github.com/ksss/mruby-method/issues/4"
end
end
assert
'Method#call with undefined method'
do
assert
'Method#call with undefined method'
do
...
...
src/kernel.c
View file @
b80e0ef7
...
@@ -869,7 +869,6 @@ mrb_init_kernel(mrb_state *mrb)
...
@@ -869,7 +869,6 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method
(
mrb
,
krn
,
"raise"
,
mrb_f_raise
,
MRB_ARGS_ANY
());
/* 15.3.1.3.40 */
mrb_define_method
(
mrb
,
krn
,
"raise"
,
mrb_f_raise
,
MRB_ARGS_ANY
());
/* 15.3.1.3.40 */
mrb_define_method
(
mrb
,
krn
,
"remove_instance_variable"
,
mrb_obj_remove_instance_variable
,
MRB_ARGS_REQ
(
1
));
/* 15.3.1.3.41 */
mrb_define_method
(
mrb
,
krn
,
"remove_instance_variable"
,
mrb_obj_remove_instance_variable
,
MRB_ARGS_REQ
(
1
));
/* 15.3.1.3.41 */
mrb_define_method
(
mrb
,
krn
,
"respond_to?"
,
obj_respond_to
,
MRB_ARGS_ANY
());
/* 15.3.1.3.43 */
mrb_define_method
(
mrb
,
krn
,
"respond_to?"
,
obj_respond_to
,
MRB_ARGS_ANY
());
/* 15.3.1.3.43 */
mrb_define_method
(
mrb
,
krn
,
"send"
,
mrb_f_send
,
MRB_ARGS_ANY
());
/* 15.3.1.3.44 */
mrb_define_method
(
mrb
,
krn
,
"to_s"
,
mrb_any_to_s
,
MRB_ARGS_NONE
());
/* 15.3.1.3.46 */
mrb_define_method
(
mrb
,
krn
,
"to_s"
,
mrb_any_to_s
,
MRB_ARGS_NONE
());
/* 15.3.1.3.46 */
mrb_define_method
(
mrb
,
krn
,
"__case_eqq"
,
mrb_obj_ceqq
,
MRB_ARGS_REQ
(
1
));
/* internal */
mrb_define_method
(
mrb
,
krn
,
"__case_eqq"
,
mrb_obj_ceqq
,
MRB_ARGS_REQ
(
1
));
/* internal */
...
...
test/t/codegen.rb
View file @
b80e0ef7
...
@@ -184,14 +184,14 @@ assert('register window of calls (#3783)') do
...
@@ -184,14 +184,14 @@ assert('register window of calls (#3783)') do
# NODE_UNDEF
# NODE_UNDEF
assert_nothing_raised do
assert_nothing_raised do
class << Object.new
class << Object.new
undef
send
undef
inspect
end
end
end
end
# NODE_ALIAS
# NODE_ALIAS
assert_nothing_raised do
assert_nothing_raised do
class << Object.new
class << Object.new
alias
send2 send
alias
inspect2 inspect
end
end
end
end
end
end
test/t/kernel.rb
View file @
b80e0ef7
...
@@ -92,20 +92,6 @@ assert('Kernel#__id__', '15.3.1.3.3') do
...
@@ -92,20 +92,6 @@ assert('Kernel#__id__', '15.3.1.3.3') do
assert_equal
Fixnum
,
__id__
.
class
assert_equal
Fixnum
,
__id__
.
class
end
end
assert
(
'Kernel#__send__'
,
'15.3.1.3.4'
)
do
# test with block
l
=
__send__
(
:lambda
)
do
true
end
assert_true
l
.
call
assert_equal
Proc
,
l
.
class
# test with argument
assert_true
__send__
(
:respond_to?
,
:nil?
)
# test without argument and without block
assert_equal
String
,
__send__
(
:to_s
).
class
end
assert
(
'Kernel#block_given?'
,
'15.3.1.3.6'
)
do
assert
(
'Kernel#block_given?'
,
'15.3.1.3.6'
)
do
def
bg_try
(
&
b
)
def
bg_try
(
&
b
)
if
block_given?
if
block_given?
...
@@ -440,20 +426,6 @@ assert('Kernel#respond_to?', '15.3.1.3.43') do
...
@@ -440,20 +426,6 @@ assert('Kernel#respond_to?', '15.3.1.3.43') do
assert_false
Test4RespondTo
.
new
.
respond_to?
(
:test_method
)
assert_false
Test4RespondTo
.
new
.
respond_to?
(
:test_method
)
end
end
assert
(
'Kernel#send'
,
'15.3.1.3.44'
)
do
# test with block
l
=
send
(
:lambda
)
do
true
end
assert_true
l
.
call
assert_equal
l
.
class
,
Proc
# test with argument
assert_true
send
(
:respond_to?
,
:nil?
)
# test without argument and without block
assert_equal
send
(
:to_s
).
class
,
String
end
assert
(
'Kernel#to_s'
,
'15.3.1.3.46'
)
do
assert
(
'Kernel#to_s'
,
'15.3.1.3.46'
)
do
assert_equal
to_s
.
class
,
String
assert_equal
to_s
.
class
,
String
end
end
...
...
test/t/module.rb
View file @
b80e0ef7
...
@@ -536,61 +536,61 @@ end
...
@@ -536,61 +536,61 @@ end
#end
#end
# mruby has no visibility control
# mruby has no visibility control
assert
'Module#prepend visibility'
do
#
assert 'Module#prepend visibility' do
bug8005
=
'[ruby-core:53106] [Bug #8005]'
#
bug8005 = '[ruby-core:53106] [Bug #8005]'
c
=
Class
.
new
do
#
c = Class.new do
prepend
Module
.
new
{}
#
prepend Module.new {}
def
foo
()
end
#
def foo() end
protected
:foo
#
protected :foo
end
#
end
a
=
c
.
new
#
a = c.new
assert_true
a
.
respond_to?
(
:foo
),
bug8005
#
assert_true a.respond_to?(:foo), bug8005
assert_nothing_raised
(
bug8005
)
{
a
.
send
:foo
}
#
assert_nothing_raised(bug8005) {a.send :foo}
end
#
end
# mruby has no visibility control
# mruby has no visibility control
assert
'Module#prepend inherited visibility'
do
#
assert 'Module#prepend inherited visibility' do
bug8238
=
'[ruby-core:54105] [Bug #8238]'
#
bug8238 = '[ruby-core:54105] [Bug #8238]'
module
Test4PrependVisibilityInherited
#
module Test4PrependVisibilityInherited
class
A
#
class A
def
foo
()
A
;
end
#
def foo() A; end
private
:foo
#
private :foo
end
#
end
class
B
<
A
#
class B < A
public
:foo
#
public :foo
prepend
Module
.
new
#
prepend Module.new
end
#
end
end
#
end
assert_equal
(
Test4PrependVisibilityInherited
::
A
,
Test4PrependVisibilityInherited
::
B
.
new
.
foo
,
"
#{
bug8238
}
"
)
#
assert_equal(Test4PrependVisibilityInherited::A, Test4PrependVisibilityInherited::B.new.foo, "#{bug8238}")
end
#
end
assert
'Module#prepend super in alias'
do
#
assert 'Module#prepend super in alias' do
skip
"super does not currently work in aliased methods"
#
skip "super does not currently work in aliased methods"
bug7842
=
'[Bug #7842]'
#
bug7842 = '[Bug #7842]'
p
=
labeled_module
(
"P"
)
do
#
p = labeled_module("P") do
def
m
;
"P"
+
super
;
end
#
def m; "P"+super; end
end
#
end
a
=
labeled_class
(
"A"
)
do
#
a = labeled_class("A") do
def
m
;
"A"
;
end
#
def m; "A"; end
end
#
end
b
=
labeled_class
(
"B"
,
a
)
do
#
b = labeled_class("B", a) do
def
m
;
"B"
+
super
;
end
#
def m; "B"+super; end
alias
m2
m
#
alias m2 m
prepend
p
#
prepend p
alias
m3
m
#
alias m3 m
end
#
end
assert_nothing_raised
do
#
assert_nothing_raised do
assert_equal
(
"BA"
,
b
.
new
.
m2
,
bug7842
)
#
assert_equal("BA", b.new.m2, bug7842)
end
#
end
assert_nothing_raised
do
#
assert_nothing_raised do
assert_equal
(
"PBA"
,
b
.
new
.
m3
,
bug7842
)
#
assert_equal("PBA", b.new.m3, bug7842)
end
#
end
end
#
end
assert
'Module#prepend each class'
do
assert
'Module#prepend each class'
do
m
=
labeled_module
(
"M"
)
m
=
labeled_module
(
"M"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment