opal 0.9.0.rc1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/opal/parser/lexer.rb +1 -1
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/array.rb +34 -34
- data/opal/corelib/constants.rb +2 -2
- data/opal/corelib/module.rb +44 -6
- data/opal/corelib/range.rb +30 -0
- data/opal/corelib/regexp.rb +15 -15
- data/opal/corelib/runtime.js +31 -15
- data/opal/corelib/string.rb +13 -4
- data/spec/filters/bugs/language.rb +90 -15
- data/spec/filters/bugs/module.rb +47 -17
- data/spec/filters/bugs/proc.rb +36 -2
- data/spec/filters/bugs/range.rb +6 -6
- data/spec/filters/bugs/unboundmethod.rb +14 -0
- data/spec/lib/parser/string_spec.rb +5 -0
- data/spec/opal/core/language/class_spec.rb +4 -4
- data/spec/opal/stdlib/native/array_spec.rb +11 -0
- data/spec/opal/stdlib/native/hash_spec.rb +8 -0
- data/spec/opal/stdlib/native/struct_spec.rb +12 -0
- data/spec/rubyspecs +4 -15
- data/stdlib/native.rb +3 -13
- data/tasks/testing.rake +1 -1
- metadata +8 -4
data/spec/filters/bugs/range.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
opal_filter "Range" do
|
2
|
-
fails "Range#bsearch raises a TypeError if the block returns a String"
|
3
|
-
fails "Range#bsearch raises a TypeError if the block returns an Object"
|
4
2
|
fails "Range#bsearch raises a TypeError if the Range has Object values"
|
5
3
|
fails "Range#bsearch raises a TypeError if the Range has String values"
|
4
|
+
fails "Range#bsearch raises a TypeError if the block returns a String"
|
5
|
+
fails "Range#bsearch raises a TypeError if the block returns an Object"
|
6
6
|
fails "Range#bsearch returns an Enumerator when not passed a block"
|
7
7
|
fails "Range#bsearch when no block is given returned Enumerator size returns nil"
|
8
8
|
fails "Range#bsearch with Float values with a block returning negative, zero, positive numbers accepts (+/-)Float::INFINITY from the block"
|
@@ -72,8 +72,8 @@ opal_filter "Range" do
|
|
72
72
|
fails "Range#max raises TypeError when called on a Time...Time(excluded end point)"
|
73
73
|
fails "Range#max raises TypeError when called on an exclusive range and a non Integer value"
|
74
74
|
fails "Range#max returns nil when the endpoint equals the start point and the range is exclusive"
|
75
|
-
fails "Range#max returns nil when the endpoint is less than the start point"
|
76
75
|
fails "Range#max returns nil when the endpoint is less than the start point in a Float range"
|
76
|
+
fails "Range#max returns nil when the endpoint is less than the start point"
|
77
77
|
fails "Range#max returns the maximum value in the range when called with no arguments"
|
78
78
|
fails "Range#member? compares values using <=>"
|
79
79
|
fails "Range#member? on string elements returns false if other is not matched by element.succ"
|
@@ -84,17 +84,17 @@ opal_filter "Range" do
|
|
84
84
|
fails "Range#member? with weird succ when included end value returns false if other is not matched by element.succ"
|
85
85
|
fails "Range#min given a block calls #> and #< on the return value of the block"
|
86
86
|
fails "Range#min returns nil when the endpoint equals the start point and the range is exclusive"
|
87
|
-
fails "Range#min returns nil when the start point is greater than the endpoint"
|
88
87
|
fails "Range#min returns nil when the start point is greater than the endpoint in a Float range"
|
88
|
+
fails "Range#min returns nil when the start point is greater than the endpoint"
|
89
89
|
fails "Range#step calls #to_int to coerce step to an Integer"
|
90
90
|
fails "Range#step coerces the argument to integer by invoking to_int"
|
91
|
+
fails "Range#step raises TypeError if step"
|
91
92
|
fails "Range#step raises a TypeError if #to_int does not return an Integer"
|
92
93
|
fails "Range#step raises a TypeError if step does not respond to #to_int"
|
93
94
|
fails "Range#step raises a TypeError if the first element does not respond to #succ"
|
94
95
|
fails "Range#step raises an ArgumentError if step is 0"
|
95
96
|
fails "Range#step raises an ArgumentError if step is 0.0"
|
96
97
|
fails "Range#step raises an ArgumentError if step is negative"
|
97
|
-
fails "Range#step raises TypeError if step"
|
98
98
|
fails "Range#step returns an enumerator when no block is given"
|
99
99
|
fails "Range#step returns self"
|
100
100
|
fails "Range#step when no block is given returned Enumerator size raises a TypeError if #to_int does not return an Integer"
|
@@ -117,9 +117,9 @@ opal_filter "Range" do
|
|
117
117
|
fails "Range#step with exclusive end and Integer values yields Float values incremented by a Float step"
|
118
118
|
fails "Range#step with exclusive end and Integer values yields Integer values incremented by 1 and less than end when not passed a step"
|
119
119
|
fails "Range#step with exclusive end and Integer values yields Integer values incremented by an Integer step"
|
120
|
-
fails "Range#step with exclusive end and Integer, Float values yields an Float and then Float values incremented by a Float step"
|
121
120
|
fails "Range#step with exclusive end and Integer, Float values yields Float values incremented by 1 and less than end when not passed a step"
|
122
121
|
fails "Range#step with exclusive end and Integer, Float values yields Float values incremented by an Integer step"
|
122
|
+
fails "Range#step with exclusive end and Integer, Float values yields an Float and then Float values incremented by a Float step"
|
123
123
|
fails "Range#step with exclusive end and String values raises a TypeError when passed a Float step"
|
124
124
|
fails "Range#step with exclusive end and String values yields String values incremented by #succ and less than or equal to end when not passed a step"
|
125
125
|
fails "Range#step with exclusive end and String values yields String values incremented by #succ called Integer step times"
|
@@ -3,6 +3,20 @@ opal_filter "UnboundMethod" do
|
|
3
3
|
fails "UnboundMethod#== returns true if either is an alias for the other"
|
4
4
|
fails "UnboundMethod#== returns true if objects refer to the same method"
|
5
5
|
fails "UnboundMethod#== returns true if same method is extracted from the same subclass"
|
6
|
+
fails "UnboundMethod#arity for a Method generated by respond_to_missing? returns -1"
|
7
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(*) end\n def n(*a) end"
|
8
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(**k, &l) end\n def n(*a, **k) end\n def o(a: 1, b: 2, **k) end"
|
9
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(*a, b) end\n def n(*a, b, c) end\n def o(*a, b, c, d) end"
|
10
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a, *) end\n def n(a, *b) end\n def o(a, b, *c) end\n def p(a, b, c, *d) end"
|
11
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a, *b, c) end\n def n(a, b, *c, d, e) end"
|
12
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a, b=1) end\n def n(a, b, c=1, d=2) end"
|
13
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a, b=1, *c, d, e:, f: 2, **k, &l) end\n def n(a, b=1, *c, d:, e:, f: 2, **k, &l) end\n def o(a=0, b=1, *c, d, e:, f: 2, **k, &l) end\n def p(a=0, b=1, *c, d:, e:, f: 2, **k, &l) end"
|
14
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a, b=1, c=2, *d, e, f) end\n def n(a, b, c=1, *d, e, f, g) end"
|
15
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a: 1) end\n def n(a: 1, b: 2) end"
|
16
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a=1) end\n def n(a=1, b=2) end"
|
17
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a=1, *b) end\n def n(a=1, b=2, *c) end"
|
18
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a=1, *b, c:, d: 2, **k, &l) end"
|
19
|
+
fails "UnboundMethod#arity returns negative values for method definition \n def m(a=1, b: 2) end\n def n(*a, b: 1) end\n def o(a=1, b: 2) end\n def p(a=1, *b, c: 2, &l) end"
|
6
20
|
fails "UnboundMethod#bind Method returned for obj is equal to one directly returned by obj.method"
|
7
21
|
fails "UnboundMethod#bind raises TypeError if object is not kind_of? the Module the method defined in"
|
8
22
|
fails "UnboundMethod#bind will raise when binding a an object singleton's method to another object"
|
@@ -121,6 +121,11 @@ describe "Strings" do
|
|
121
121
|
parsed('%[]').should == [:str, '']
|
122
122
|
parsed('%[foo]').should == [:str, 'foo']
|
123
123
|
end
|
124
|
+
|
125
|
+
it "parses %<> strings" do
|
126
|
+
parsed('%<>').should == [:str, '']
|
127
|
+
parsed('%<foo>').should == [:str, 'foo']
|
128
|
+
end
|
124
129
|
end
|
125
130
|
|
126
131
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class AssignClassNewConst
|
2
2
|
TEST_CONST = :bar
|
3
|
-
|
3
|
+
|
4
4
|
def foo
|
5
5
|
TEST_CONST
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def self.assign_klass
|
9
9
|
k = Class.new(self) do
|
10
10
|
def foobar
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
module AssignClassConstBase
|
20
20
|
def self.assign_const(group)
|
21
|
-
self.const_set("MyStuff", group)
|
21
|
+
self.const_set("MyStuff", group)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -43,7 +43,7 @@ describe "Assigning Class.new to a constant" do
|
|
43
43
|
ConstantWithAssignedClass.new.foo.should == :foo
|
44
44
|
ConstantWithAssignedClass.new.bar.should == :bar
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "respects a different base scope" do
|
48
48
|
AssignClassNewConst.assign_klass
|
49
49
|
AssignClassConstBase::MyStuff.to_s.should == "AssignClassConstBase::MyStuff"
|
@@ -33,4 +33,12 @@ describe Hash do
|
|
33
33
|
|
34
34
|
expect(h).to eq(expected_hash)
|
35
35
|
end
|
36
|
+
|
37
|
+
describe '#to_n' do
|
38
|
+
it 'converts a hash with native objects as values' do
|
39
|
+
obj = { 'a_key' => `{ key: 1 }` }
|
40
|
+
native = obj.to_n
|
41
|
+
`#{native}.a_key.key`.should == 1
|
42
|
+
end
|
43
|
+
end
|
36
44
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'native'
|
2
|
+
|
3
|
+
describe Struct do
|
4
|
+
describe '#to_n' do
|
5
|
+
it 'converts a struct with native attributes to a JS object' do
|
6
|
+
klass = Struct.new(:attribute)
|
7
|
+
obj = klass.new(`{ key: 1 }`)
|
8
|
+
native = obj.to_n
|
9
|
+
`#{native}.attribute.key`.should == 1
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/rubyspecs
CHANGED
@@ -3,6 +3,10 @@ rubyspec/core/basicobject
|
|
3
3
|
rubyspec/core/builtin_constants
|
4
4
|
rubyspec/core/class
|
5
5
|
rubyspec/core/comparable
|
6
|
+
|
7
|
+
rubyspec/core/complex
|
8
|
+
!rubyspec/core/complex/marshal_dump_spec
|
9
|
+
|
6
10
|
rubyspec/core/enumerable
|
7
11
|
rubyspec/core/enumerator
|
8
12
|
|
@@ -63,27 +67,19 @@ rubyspec/core/math
|
|
63
67
|
# rubyspec/core/method - cannot parse `def one_splat_one_req(*a,b); end`
|
64
68
|
|
65
69
|
rubyspec/core/module
|
66
|
-
!rubyspec/core/module/autoload_spec
|
67
70
|
!rubyspec/core/module/const_defined_spec
|
68
|
-
!rubyspec/core/module/const_set_spec
|
69
|
-
!rubyspec/core/module/name_spec
|
70
71
|
|
71
72
|
rubyspec/core/nil
|
72
73
|
rubyspec/core/numeric
|
73
74
|
|
74
75
|
rubyspec/core/proc
|
75
|
-
!rubyspec/core/proc/arity_spec
|
76
76
|
!rubyspec/core/proc/parameters_spec
|
77
77
|
|
78
78
|
rubyspec/core/range
|
79
|
-
!rubyspec/core/range/to_a_spec
|
80
79
|
|
81
80
|
rubyspec/core/rational
|
82
81
|
!rubyspec/core/rational/marshal_dump_spec
|
83
82
|
|
84
|
-
rubyspec/core/complex
|
85
|
-
!rubyspec/core/complex/marshal_dump_spec
|
86
|
-
|
87
83
|
rubyspec/core/regexp
|
88
84
|
!rubyspec/core/regexp/named_captures_spec
|
89
85
|
!rubyspec/core/regexp/names_spec
|
@@ -102,9 +98,7 @@ rubyspec/core/time
|
|
102
98
|
!rubyspec/core/time/_load_spec
|
103
99
|
|
104
100
|
rubyspec/core/true
|
105
|
-
|
106
101
|
rubyspec/core/unboundmethod
|
107
|
-
!rubyspec/core/unboundmethod/arity_spec
|
108
102
|
|
109
103
|
rubyspec/language
|
110
104
|
!rubyspec/language/block_spec
|
@@ -114,19 +108,14 @@ rubyspec/language
|
|
114
108
|
!rubyspec/language/encoding_spec
|
115
109
|
!rubyspec/language/execution_spec
|
116
110
|
!rubyspec/language/hash_spec
|
117
|
-
!rubyspec/language/lambda_spec
|
118
|
-
!rubyspec/language/line_spec
|
119
|
-
!rubyspec/language/match_spec
|
120
111
|
!rubyspec/language/method_spec
|
121
112
|
!rubyspec/language/next_spec
|
122
113
|
!rubyspec/language/predefined_spec
|
123
114
|
!rubyspec/language/proc_spec
|
124
|
-
!rubyspec/language/regexp_spec
|
125
115
|
!rubyspec/language/return_spec
|
126
116
|
!rubyspec/language/send_spec
|
127
117
|
!rubyspec/language/string_spec
|
128
118
|
!rubyspec/language/symbol_spec
|
129
|
-
!rubyspec/language/while_spec
|
130
119
|
!rubyspec/language/yield_spec
|
131
120
|
|
132
121
|
rubyspec/library/date
|
data/stdlib/native.rb
CHANGED
@@ -476,7 +476,7 @@ class Struct
|
|
476
476
|
result = `{}`
|
477
477
|
|
478
478
|
each_pair {|name, value|
|
479
|
-
`#{result}[#{name}] = #{value
|
479
|
+
`#{result}[#{name}] = #{Native.try_convert(value)}`
|
480
480
|
}
|
481
481
|
|
482
482
|
result
|
@@ -492,12 +492,7 @@ class Array
|
|
492
492
|
for (var i = 0, length = self.length; i < length; i++) {
|
493
493
|
var obj = self[i];
|
494
494
|
|
495
|
-
|
496
|
-
result.push(#{`obj`.to_n});
|
497
|
-
}
|
498
|
-
else {
|
499
|
-
result.push(obj);
|
500
|
-
}
|
495
|
+
result.push(#{Native.try_convert(`obj`)});
|
501
496
|
}
|
502
497
|
|
503
498
|
return result;
|
@@ -583,12 +578,7 @@ class Hash
|
|
583
578
|
value = key.value;
|
584
579
|
}
|
585
580
|
|
586
|
-
|
587
|
-
result[key] = #{`value`.to_n};
|
588
|
-
}
|
589
|
-
else {
|
590
|
-
result[key] = value;
|
591
|
-
}
|
581
|
+
result[key] = #{Native.try_convert(`value`)};
|
592
582
|
}
|
593
583
|
|
594
584
|
return result;
|
data/tasks/testing.rake
CHANGED
@@ -119,7 +119,7 @@ DESC
|
|
119
119
|
Opal::Config.arity_check_enabled = true
|
120
120
|
Opal::Config.freezing_stubs_enabled = true
|
121
121
|
Opal::Config.tainting_stubs_enabled = false
|
122
|
-
Opal::Config.dynamic_require_severity = :
|
122
|
+
Opal::Config.dynamic_require_severity = :warning
|
123
123
|
|
124
124
|
Opal.use_gem 'mspec'
|
125
125
|
Opal.append_path 'spec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sourcemap
|
@@ -783,6 +783,7 @@ files:
|
|
783
783
|
- spec/opal/stdlib/json/ext_spec.rb
|
784
784
|
- spec/opal/stdlib/json/parse_spec.rb
|
785
785
|
- spec/opal/stdlib/native/alias_native_spec.rb
|
786
|
+
- spec/opal/stdlib/native/array_spec.rb
|
786
787
|
- spec/opal/stdlib/native/each_spec.rb
|
787
788
|
- spec/opal/stdlib/native/element_reference_spec.rb
|
788
789
|
- spec/opal/stdlib/native/exposure_spec.rb
|
@@ -796,6 +797,7 @@ files:
|
|
796
797
|
- spec/opal/stdlib/native/native_reader_spec.rb
|
797
798
|
- spec/opal/stdlib/native/native_writer_spec.rb
|
798
799
|
- spec/opal/stdlib/native/new_spec.rb
|
800
|
+
- spec/opal/stdlib/native/struct_spec.rb
|
799
801
|
- spec/opal/stdlib/promise/always_spec.rb
|
800
802
|
- spec/opal/stdlib/promise/error_spec.rb
|
801
803
|
- spec/opal/stdlib/promise/rescue_spec.rb
|
@@ -1097,9 +1099,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1097
1099
|
version: 1.9.3
|
1098
1100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1099
1101
|
requirements:
|
1100
|
-
- - "
|
1102
|
+
- - ">="
|
1101
1103
|
- !ruby/object:Gem::Version
|
1102
|
-
version:
|
1104
|
+
version: '0'
|
1103
1105
|
requirements: []
|
1104
1106
|
rubyforge_project:
|
1105
1107
|
rubygems_version: 2.4.8
|
@@ -1432,6 +1434,7 @@ test_files:
|
|
1432
1434
|
- spec/opal/stdlib/json/ext_spec.rb
|
1433
1435
|
- spec/opal/stdlib/json/parse_spec.rb
|
1434
1436
|
- spec/opal/stdlib/native/alias_native_spec.rb
|
1437
|
+
- spec/opal/stdlib/native/array_spec.rb
|
1435
1438
|
- spec/opal/stdlib/native/each_spec.rb
|
1436
1439
|
- spec/opal/stdlib/native/element_reference_spec.rb
|
1437
1440
|
- spec/opal/stdlib/native/exposure_spec.rb
|
@@ -1445,6 +1448,7 @@ test_files:
|
|
1445
1448
|
- spec/opal/stdlib/native/native_reader_spec.rb
|
1446
1449
|
- spec/opal/stdlib/native/native_writer_spec.rb
|
1447
1450
|
- spec/opal/stdlib/native/new_spec.rb
|
1451
|
+
- spec/opal/stdlib/native/struct_spec.rb
|
1448
1452
|
- spec/opal/stdlib/promise/always_spec.rb
|
1449
1453
|
- spec/opal/stdlib/promise/error_spec.rb
|
1450
1454
|
- spec/opal/stdlib/promise/rescue_spec.rb
|