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
3cba13c2
Unverified
Commit
3cba13c2
authored
Dec 21, 2016
by
ksss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proc shouldn't have `initialize` method
Fix #3356
parent
987daa64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
44 deletions
+6
-44
mrbgems/mruby-proc-ext/test/proc.rb
mrbgems/mruby-proc-ext/test/proc.rb
+0
-11
src/proc.c
src/proc.c
+6
-6
test/t/proc.rb
test/t/proc.rb
+0
-27
No files found.
mrbgems/mruby-proc-ext/test/proc.rb
View file @
3cba13c2
...
...
@@ -58,17 +58,6 @@ assert('Proc#parameters') do
assert_equal
([[
:req
,
:a
],
[
:req
,
:b
],
[
:opt
,
:c
],
[
:opt
,
:d
],
[
:rest
,
:e
],
[
:req
,
:f
],
[
:req
,
:g
],
[
:block
,
:h
]],
lambda
{
|
a
,
b
,
c
=
:c
,
d
=
:d
,
*
e
,
f
,
g
,
&
h
|
}.
parameters
)
end
assert
(
'Proc#parameters with uninitialized Proc'
)
do
begin
Proc
.
alias_method
(
:original_initialize
,
:initialize
)
Proc
.
remove_method
(
:initialize
)
assert_equal
[],
Proc
.
new
{
|
a
,
b
,
c
|
1
}.
parameters
ensure
Proc
.
alias_method
(
:initialize
,
:original_initialize
)
Proc
.
remove_method
(
:original_initialize
)
end
end
assert
(
'Proc#to_proc'
)
do
proc
=
Proc
.
new
{}
assert_equal
proc
,
proc
.
to_proc
...
...
src/proc.c
View file @
3cba13c2
...
...
@@ -148,19 +148,19 @@ mrb_proc_copy(struct RProc *a, struct RProc *b)
}
static
mrb_value
mrb_proc_
initialize
(
mrb_state
*
mrb
,
mrb_value
self
)
mrb_proc_
s_new
(
mrb_state
*
mrb
,
mrb_value
proc_class
)
{
mrb_value
blk
;
struct
RProc
*
p
;
mrb_get_args
(
mrb
,
"&"
,
&
blk
);
if
(
mrb_nil_p
(
blk
))
{
/* Calling Proc.new without a block is not implemented yet */
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"tried to create Proc object without a block"
);
}
else
{
mrb_proc_copy
(
mrb_proc_ptr
(
self
),
mrb_proc_ptr
(
blk
));
}
return
self
;
p
=
(
struct
RProc
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_PROC
,
mrb_class_ptr
(
proc_class
));
mrb_proc_copy
(
p
,
mrb_proc_ptr
(
blk
));
return
mrb_obj_value
(
p
);
}
static
mrb_value
...
...
@@ -268,7 +268,7 @@ mrb_init_proc(mrb_state *mrb)
call_irep
->
iseq
=
call_iseq
;
call_irep
->
ilen
=
1
;
mrb_define_
method
(
mrb
,
mrb
->
proc_class
,
"initialize"
,
mrb_proc_initialize
,
MRB_ARGS_NONE
());
mrb_define_
class_method
(
mrb
,
mrb
->
proc_class
,
"new"
,
mrb_proc_s_new
,
MRB_ARGS_ANY
());
mrb_define_method
(
mrb
,
mrb
->
proc_class
,
"initialize_copy"
,
mrb_proc_init_copy
,
MRB_ARGS_REQ
(
1
));
mrb_define_method
(
mrb
,
mrb
->
proc_class
,
"arity"
,
mrb_proc_arity
,
MRB_ARGS_NONE
());
...
...
test/t/proc.rb
View file @
3cba13c2
...
...
@@ -46,17 +46,6 @@ assert('Proc#arity', '15.2.17.4.2') do
assert_equal
(
-
1
,
g
)
end
assert
(
'Proc#arity with unitialized Proc'
)
do
begin
Proc
.
alias_method
(
:original_initialize
,
:initialize
)
Proc
.
remove_method
(
:initialize
)
assert_equal
0
,
Proc
.
new
{
|
a
,
b
,
c
|
1
}.
arity
ensure
Proc
.
alias_method
(
:initialize
,
:original_initialize
)
Proc
.
remove_method
(
:original_initialize
)
end
end
assert
(
'Proc#call'
,
'15.2.17.4.3'
)
do
a
=
0
b
=
Proc
.
new
{
a
+=
1
}
...
...
@@ -163,19 +152,3 @@ assert('&obj call to_proc if defined') do
assert_raise
(
TypeError
){
mock
(
&
(
Object
.
new
))
}
end
assert
(
'initialize_copy works when initialize is removed'
)
do
begin
Proc
.
alias_method
(
:old_initialize
,
:initialize
)
Proc
.
remove_method
(
:initialize
)
a
=
Proc
.
new
{}
b
=
Proc
.
new
{}
assert_nothing_raised
do
a
.
initialize_copy
(
b
)
end
ensure
Proc
.
alias_method
(
:initialize
,
:old_initialize
)
Proc
.
remove_method
(
:old_initialize
)
end
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