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
c7cff199
Commit
c7cff199
authored
Jan 16, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hash value of enumerable should be obtained from its elements; close #1658
parent
e63c1e1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
mrblib/enum.rb
mrblib/enum.rb
+9
-0
mrblib/range.rb
mrblib/range.rb
+9
-0
test/t/array.rb
test/t/array.rb
+1
-3
No files found.
mrblib/enum.rb
View file @
c7cff199
...
...
@@ -395,4 +395,13 @@ module Enumerable
#
# ISO 15.3.2.2.20
alias
to_a
entries
# redefine #hash 15.3.1.3.15
def
hash
h
=
12347
self
.
each
do
|
e
|
h
^=
e
.
hash
end
h
end
end
mrblib/range.rb
View file @
c7cff199
...
...
@@ -28,6 +28,15 @@ class Range
end
self
end
# redefine #hash 15.3.1.3.15
def
hash
h
=
first
.
hash
^
last
.
hash
if
self
.
exclude_end?
h
+=
1
end
h
end
end
##
...
...
test/t/array.rb
View file @
c7cff199
...
...
@@ -301,6 +301,7 @@ assert('Array#hash', '15.2.12.5.35') do
a
=
[
1
,
2
,
3
]
assert_true
(
a
.
hash
.
is_a?
Integer
)
assert_equal
([
1
,
2
].
hash
,
[
1
,
2
].
hash
)
end
assert
(
'Array#<=>'
,
'15.2.12.5.36'
)
do
...
...
@@ -328,6 +329,3 @@ assert("Array (Longish inline array)") do
ary
.
each
{
|
p
|
h
[
p
.
class
]
+=
1
}
assert_equal
({
Array
=>
200
},
h
)
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