Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e86e742

Browse files
committedOct 31, 2014
WIP
1 parent 9b407e6 commit e86e742

File tree

6 files changed

+411
-94
lines changed

6 files changed

+411
-94
lines changed
 

‎Rakefile

+3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ task :mspec_node do
4141

4242
if pattern
4343
custom = Dir[pattern]
44+
p custom.size
45+
p rubyspecs.grep /hash/
4446
custom &= rubyspecs if whitelist_pattern
47+
p whitelist_pattern, custom.size
4548
specs = add_specs.(:custom, custom)
4649
else
4750
specs = add_specs.(:shared, shared)

‎benchmarks/prova.js.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 'asdf' =~ /(a)./
2+
#
3+
# p $'
4+
# p $1
5+
# p $2
6+
# `console.log(2, $opal.gvars['1'])`
7+
# b = $1
8+
# `console.log(1, b)`
9+
# nil
10+
11+
puts [*1..3].to_s
12+
puts [*(1..3)].to_s
13+
puts [*Object.new].to_s

‎lib/mspec/opal/runner.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ def log(str)
159159

160160
def after(state)
161161
super
162+
print_example(state)
163+
end
164+
165+
def print_example(state)
162166
unless exception?
163167
green('.')
164168
else
@@ -176,13 +180,19 @@ def finish
176180
end
177181
end
178182

179-
class PhantomDebugFormatter < PhantomFormatter
183+
class PhantomDocFormatter < PhantomFormatter
180184
def after(state = nil)
181185
(@exception && state) ? red(state.description) : green(state.description)
182186
super
183187
end
184188
end
185189

190+
class NodeJSDocFormatter < NodeJSFormatter
191+
def print_example(state)
192+
(@exception && state) ? red(state.description+"\n") : green(state.description+"\n")
193+
end
194+
end
195+
186196
module MSpec
187197
def self.opal_runner
188198
@env = Object.new

‎opal/corelib/hash.rb

+361-87
Large diffs are not rendered by default.

‎opal/corelib/runtime.js

+22-5
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,12 @@
959959

960960
var hash = new Opal.Hash.$$alloc(),
961961
keys = [],
962-
map = {},
962+
_map = {},
963+
smap = {},
963964
key, obj, length, khash;
964965

965-
hash.map = map;
966+
hash.map = _map;
967+
hash.smap = smap;
966968
hash.keys = keys;
967969

968970
if (arguments.length == 1) {
@@ -978,7 +980,14 @@
978980

979981
key = pair[0];
980982
obj = pair[1];
981-
khash = key.$hash();
983+
984+
if (key.$$is_string) {
985+
khash = key;
986+
map = smap;
987+
} else {
988+
khash = key.$hash();
989+
map = _map;
990+
}
982991

983992
if (map[khash] == null) {
984993
keys.push(key);
@@ -1005,7 +1014,14 @@
10051014
for (var j = 0; j < length; j++) {
10061015
key = arguments[j];
10071016
obj = arguments[++j];
1008-
khash = key.$hash();
1017+
1018+
if (key.$$is_string) {
1019+
khash = key;
1020+
map = smap;
1021+
} else {
1022+
khash = key.$hash();
1023+
map = _map;
1024+
}
10091025

10101026
if (map[khash] == null) {
10111027
keys.push(key);
@@ -1028,7 +1044,8 @@
10281044
var hash = new Opal.Hash.$$alloc();
10291045

10301046
hash.keys = keys;
1031-
hash.map = map;
1047+
hash.map = {};
1048+
hash.smap = map;
10321049

10331050
return hash;
10341051
};

‎spec/spec_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def at_exit(&block)
2828

2929
case
3030
when defined?(NodeJS)
31-
formatter_class = NodeJSFormatter
31+
formatter_class = NodeJSDocFormatter
3232
when `(typeof(window) !== 'undefined')`
3333
if `!!window.OPAL_SPEC_PHANTOM`
3434
require 'phantomjs'

0 commit comments

Comments
 (0)
Please sign in to comment.