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
030dd665
Commit
030dd665
authored
Jun 16, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cvar, ivar, const and method can be removed to frozen object
parent
ab5ffb30
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
2 deletions
+10
-2
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
+6
-2
src/variable.c
src/variable.c
+1
-0
test/t/kernel.rb
test/t/kernel.rb
+1
-0
test/t/module.rb
test/t/module.rb
+1
-0
No files found.
mrbgems/mruby-metaprog/src/metaprog.c
View file @
030dd665
...
@@ -641,6 +641,7 @@ mrb_mod_remove_method(mrb_state *mrb, mrb_value mod)
...
@@ -641,6 +641,7 @@ mrb_mod_remove_method(mrb_state *mrb, mrb_value mod)
mrb_value
*
argv
;
mrb_value
*
argv
;
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
mrb_check_frozen
(
mrb
,
mrb_obj_ptr
(
mod
));
while
(
argc
--
)
{
while
(
argc
--
)
{
remove_method
(
mrb
,
mod
,
mrb_obj_to_sym
(
mrb
,
*
argv
));
remove_method
(
mrb
,
mod
,
mrb_obj_to_sym
(
mrb
,
*
argv
));
argv
++
;
argv
++
;
...
...
mrbgems/mruby-metaprog/test/metaprog.rb
View file @
030dd665
...
@@ -298,6 +298,9 @@ assert('Module#remove_class_variable', '15.2.2.4.39') do
...
@@ -298,6 +298,9 @@ assert('Module#remove_class_variable', '15.2.2.4.39') do
assert_raise
(
NameError
)
do
assert_raise
(
NameError
)
do
Test4RemoveClassVariable
.
remove_class_variable
(
:@v
)
Test4RemoveClassVariable
.
remove_class_variable
(
:@v
)
end
end
assert_raise
(
FrozenError
)
do
Test4RemoveClassVariable
.
freeze
.
remove_class_variable
(
:@@cv
)
end
end
end
assert
(
'Module#remove_method'
,
'15.2.2.4.41'
)
do
assert
(
'Module#remove_method'
,
'15.2.2.4.41'
)
do
...
@@ -317,6 +320,7 @@ assert('Module#remove_method', '15.2.2.4.41') do
...
@@ -317,6 +320,7 @@ assert('Module#remove_method', '15.2.2.4.41') do
assert_same
klass
,
klass
.
class_eval
{
remove_method
:hello
}
assert_same
klass
,
klass
.
class_eval
{
remove_method
:hello
}
assert_true
klass
.
instance_methods
.
include?
:hello
assert_true
klass
.
instance_methods
.
include?
:hello
assert_false
klass
.
instance_methods
(
false
).
include?
:hello
assert_false
klass
.
instance_methods
(
false
).
include?
:hello
assert_raise
(
FrozenError
)
{
klass
.
freeze
.
remove_method
:m
}
end
end
assert
(
'Module.nesting'
,
'15.2.2.2.2'
)
do
assert
(
'Module.nesting'
,
'15.2.2.2.2'
)
do
...
...
src/variable.c
View file @
030dd665
...
@@ -521,6 +521,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
...
@@ -521,6 +521,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
MRB_API
mrb_value
MRB_API
mrb_value
mrb_iv_remove
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
)
mrb_iv_remove
(
mrb_state
*
mrb
,
mrb_value
obj
,
mrb_sym
sym
)
{
{
mrb_check_frozen
(
mrb
,
mrb_obj_ptr
(
obj
));
if
(
obj_iv_p
(
obj
))
{
if
(
obj_iv_p
(
obj
))
{
iv_tbl
*
t
=
mrb_obj_ptr
(
obj
)
->
iv
;
iv_tbl
*
t
=
mrb_obj_ptr
(
obj
)
->
iv
;
mrb_value
val
;
mrb_value
val
;
...
...
test/t/kernel.rb
View file @
030dd665
...
@@ -404,6 +404,7 @@ assert('Kernel#remove_instance_variable', '15.3.1.3.41') do
...
@@ -404,6 +404,7 @@ assert('Kernel#remove_instance_variable', '15.3.1.3.41') do
assert_equal
nil
,
tri
.
var
assert_equal
nil
,
tri
.
var
assert_raise
(
NameError
)
{
tri
.
remove
}
assert_raise
(
NameError
)
{
tri
.
remove
}
assert_raise
(
NameError
)
{
tri
.
remove_instance_variable
(
:var
)
}
assert_raise
(
NameError
)
{
tri
.
remove_instance_variable
(
:var
)
}
assert_raise
(
FrozenError
)
{
tri
.
freeze
.
remove
}
end
end
# Kernel#require is defined in mruby-require. '15.3.1.3.42'
# Kernel#require is defined in mruby-require. '15.3.1.3.42'
...
...
test/t/module.rb
View file @
030dd665
...
@@ -262,6 +262,7 @@ assert('Module#remove_const', '15.2.2.4.40') do
...
@@ -262,6 +262,7 @@ assert('Module#remove_const', '15.2.2.4.40') do
%i[x X!]
.
each
do
|
n
|
%i[x X!]
.
each
do
|
n
|
assert_raise
(
NameError
)
{
Test4RemoveConst
.
remove_const
(
n
)
}
assert_raise
(
NameError
)
{
Test4RemoveConst
.
remove_const
(
n
)
}
end
end
assert_raise
(
FrozenError
)
{
Test4RemoveConst
.
freeze
.
remove_const
(
:A
)
}
end
end
assert
(
'Module#const_missing'
,
'15.2.2.4.22'
)
do
assert
(
'Module#const_missing'
,
'15.2.2.4.22'
)
do
...
...
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