Skip to content

Commit dbc1bd8

Browse files
committedOct 27, 2014
Merge pull request #628 from opal/hash-hash
Use #hash to build Hash hash-tables #️⃣
2 parents 266b44e + f11882b commit dbc1bd8

File tree

13 files changed

+183
-177
lines changed

13 files changed

+183
-177
lines changed
 

‎.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "spec/corelib"]
22
path = spec/corelib
3-
url = https://github.com/rubyspec/rubyspec
3+
url = https://github.com/opal/rubyspec
44
[submodule "spec/stdlib/rubysl-singleton"]
55
path = spec/stdlib/rubysl-singleton
66
url = https://github.com/rubysl/rubysl-singleton

‎Rakefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,21 @@ task :mspec_node do
3232
filters = Dir['spec/filters/**/*.rb']
3333
shared = Dir['spec/{opal,lib/parser}/**/*_spec.rb'] + ['spec/lib/lexer_spec.rb']
3434

35-
p [rubyspecs.size, :rubyspecs]
36-
p [filters.size, :filters]
37-
p [shared.size, :shared]
38-
3935
specs = []
40-
specs += filters
41-
specs += rubyspecs
42-
specs += shared
36+
add_specs = ->(name, new_specs) { p [new_specs.size, name]; specs + new_specs}
37+
38+
specs = add_specs.(:filters, filters)
39+
pattern = ENV['PATTERN']
40+
whitelist_pattern = !!ENV['RUBYSPECS']
41+
42+
if pattern
43+
custom = Dir[pattern]
44+
custom &= rubyspecs if whitelist_pattern
45+
specs = add_specs.(:custom, custom)
46+
else
47+
specs = add_specs.(:shared, shared)
48+
specs = add_specs.(:rubyspecs, rubyspecs)
49+
end
4350

4451
requires = specs.map{|s| "require '#{s.sub(/^spec\//,'')}'"}
4552
filename = 'tmp/mspec_node.rb'

‎lib/opal/nodes/top.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'pathname'
12
require 'opal/version'
23
require 'opal/nodes/scope'
34

‎opal/corelib/array.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,16 @@ def flatten!(level = undefined)
916916
end
917917

918918
def hash
919-
`self.$$id || (self.$$id = Opal.uid())`
919+
%x{
920+
var hash = ['A'], item, item_hash;
921+
for (var i = 0, length = self.length; i < length; i++) {
922+
item = self[i];
923+
// Guard against recursion
924+
item_hash = self === item ? 'self' : item.$hash();
925+
hash.push(item_hash);
926+
}
927+
return hash.join(',');
928+
}
920929
end
921930

922931
def include?(member)

0 commit comments

Comments
 (0)
Please sign in to comment.