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
a70419bc
Commit
a70419bc
authored
Apr 20, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1194 from carsonmcdonald/rtomissingimpl
Implement respond_to_missing?
parents
cc512dd8
93b23357
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
src/kernel.c
src/kernel.c
+8
-1
test/t/kernel.rb
test/t/kernel.rb
+13
-0
No files found.
src/kernel.c
View file @
a70419bc
...
...
@@ -965,7 +965,7 @@ obj_respond_to(mrb_state *mrb, mrb_value self)
mrb_value
*
argv
;
int
argc
;
mrb_value
mid
,
priv
;
mrb_sym
id
;
mrb_sym
id
,
rtm_id
;
mrb_bool
respond_to_p
;
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
...
...
@@ -976,6 +976,13 @@ obj_respond_to(mrb_state *mrb, mrb_value self)
respond_to_p
=
basic_obj_respond_to
(
mrb
,
self
,
id
,
!
mrb_test
(
priv
));
if
(
!
respond_to_p
)
{
rtm_id
=
mrb_intern2
(
mrb
,
"respond_to_missing?"
,
19
);
if
(
basic_obj_respond_to
(
mrb
,
self
,
rtm_id
,
!
mrb_test
(
priv
)))
{
return
mrb_funcall_argv
(
mrb
,
self
,
rtm_id
,
argc
,
argv
);
}
}
return
mrb_bool_value
(
respond_to_p
);
}
...
...
test/t/kernel.rb
View file @
a70419bc
...
...
@@ -392,3 +392,16 @@ assert('Kernel#!=') do
(
str1
!=
str3
)
==
true
and
(
str2
!=
str1
)
==
false
end
assert
(
'Kernel#respond_to_missing?'
)
do
class
Test4RespondToMissing
def
respond_to_missing?
(
method_name
,
include_private
=
false
)
method_name
==
:a_method
end
end
Test4RespondToMissing
.
new
.
respond_to?
(
:a_method
)
==
true
and
Test4RespondToMissing
.
new
.
respond_to?
(
:no_method
)
==
false
end
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