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
c35a25c5
Commit
c35a25c5
authored
Jan 28, 2016
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3091 from visualsayed/fix_hash_replace_method
protect NoMethodError from calling to_hash in replace
parents
2723b10a
f5f48d94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
mrblib/hash.rb
mrblib/hash.rb
+1
-0
test/t/hash.rb
test/t/hash.rb
+4
-0
No files found.
mrblib/hash.rb
View file @
c35a25c5
...
...
@@ -154,6 +154,7 @@ class Hash
#
# ISO 15.2.13.4.23
def
replace
(
hash
)
raise
TypeError
,
"can't convert argument into Hash"
unless
hash
.
respond_to?
(
:to_hash
)
self
.
clear
hash
=
hash
.
to_hash
hash
.
each_key
{
|
k
|
...
...
test/t/hash.rb
View file @
c35a25c5
...
...
@@ -239,6 +239,10 @@ assert('Hash#replace', '15.2.13.4.23') do
a
=
Hash
.
new
{
|
h
,
x
|
x
}
b
.
replace
(
a
)
assert_equal
(
127
,
b
[
127
])
assert_raise
(
TypeError
)
do
{
'abc_key'
=>
'abc_value'
}.
replace
"a"
end
end
assert
(
'Hash#shift'
,
'15.2.13.4.24'
)
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