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
b4657182
Commit
b4657182
authored
May 13, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert &arg using to_proc; fix #2242
parent
bcbf078e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
src/vm.c
src/vm.c
+3
-0
test/t/proc.rb
test/t/proc.rb
+17
-0
No files found.
src/vm.c
View file @
b4657182
...
...
@@ -1286,6 +1286,9 @@ RETRY_TRY_BLOCK:
int
len
=
m1
+
o
+
r
+
m2
;
mrb_value
*
blk
=
&
argv
[
argc
<
0
?
1
:
argc
];
if
(
!
mrb_nil_p
(
*
blk
)
&&
mrb_type
(
*
blk
)
!=
MRB_TT_PROC
)
{
*
blk
=
mrb_convert_type
(
mrb
,
*
blk
,
MRB_TT_PROC
,
"Proc"
,
"to_proc"
);
}
if
(
argc
<
0
)
{
struct
RArray
*
ary
=
mrb_ary_ptr
(
regs
[
1
]);
argv
=
ary
->
ptr
;
...
...
test/t/proc.rb
View file @
b4657182
...
...
@@ -131,3 +131,20 @@ assert('Proc#return_does_not_break_self') do
assert_equal
nil
,
c
.
return_nil
assert_equal
c
,
c
.
block
.
call
end
assert
(
'&obj call to_proc if defined'
)
do
pr
=
Proc
.
new
{}
def
mock
(
&
b
)
b
end
assert_equal
pr
.
object_id
,
mock
(
&
pr
).
object_id
assert_equal
pr
,
mock
(
&
pr
)
obj
=
Object
.
new
def
obj
.
to_proc
Proc
.
new
{
:from_to_proc
}
end
assert_equal
:from_to_proc
,
mock
(
&
obj
).
call
assert_raise
(
TypeError
){
mock
(
&
(
Object
.
new
))
}
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