opal 1.8.0.alpha1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -0
- data/CHANGELOG.md +119 -2
- data/README.md +7 -7
- data/UNRELEASED.md +1 -78
- data/docs/releasing.md +8 -16
- data/lib/opal/cli_runners/chrome.rb +5 -1
- data/lib/opal/nodes/closure.rb +15 -7
- data/lib/opal/nodes/defined.rb +1 -1
- data/lib/opal/nodes/literal.rb +10 -6
- data/lib/opal/nodes/rescue.rb +1 -1
- data/lib/opal/simple_server.rb +2 -2
- data/lib/opal/version.rb +1 -1
- data/opal/corelib/array.rb +39 -21
- data/opal/corelib/class.rb +26 -8
- data/opal/corelib/complex.rb +1 -1
- data/opal/corelib/constants.rb +2 -2
- data/opal/corelib/enumerator/arithmetic_sequence.rb +1 -1
- data/opal/corelib/error.rb +10 -0
- data/opal/corelib/hash.rb +36 -20
- data/opal/corelib/kernel.rb +0 -1
- data/opal/corelib/method.rb +1 -0
- data/opal/corelib/module.rb +82 -22
- data/opal/corelib/number.rb +28 -1
- data/opal/corelib/range.rb +55 -11
- data/opal/corelib/rational.rb +1 -1
- data/opal/corelib/runtime.js +132 -50
- data/opal/corelib/string.rb +36 -8
- data/opal/corelib/struct.rb +1 -1
- data/opal/corelib/time.rb +1 -1
- data/spec/filters/bugs/array.rb +58 -0
- data/spec/filters/bugs/basicobject.rb +7 -0
- data/spec/filters/bugs/bigdecimal.rb +1 -2
- data/spec/filters/bugs/binding.rb +1 -0
- data/spec/filters/bugs/cgi.rb +40 -0
- data/spec/filters/bugs/class.rb +2 -3
- data/spec/filters/bugs/complex.rb +3 -0
- data/spec/filters/bugs/date.rb +5 -2
- data/spec/filters/bugs/datetime.rb +1 -0
- data/spec/filters/bugs/delegate.rb +1 -2
- data/spec/filters/bugs/encoding.rb +1 -1
- data/spec/filters/bugs/enumerable.rb +11 -0
- data/spec/filters/bugs/enumerator.rb +15 -2
- data/spec/filters/bugs/exception.rb +9 -4
- data/spec/filters/bugs/file.rb +2 -0
- data/spec/filters/bugs/float.rb +1 -0
- data/spec/filters/bugs/freeze.rb +5 -49
- data/spec/filters/bugs/hash.rb +1 -0
- data/spec/filters/bugs/integer.rb +5 -6
- data/spec/filters/bugs/kernel.rb +12 -6
- data/spec/filters/bugs/language.rb +33 -15
- data/spec/filters/bugs/marshal.rb +63 -4
- data/spec/filters/bugs/method.rb +2 -13
- data/spec/filters/bugs/module.rb +19 -17
- data/spec/filters/bugs/objectspace.rb +2 -0
- data/spec/filters/bugs/pathname.rb +1 -0
- data/spec/filters/bugs/proc.rb +4 -2
- data/spec/filters/bugs/random.rb +0 -3
- data/spec/filters/bugs/range.rb +3 -17
- data/spec/filters/bugs/rational.rb +2 -0
- data/spec/filters/bugs/refinement.rb +19 -0
- data/spec/filters/bugs/regexp.rb +27 -5
- data/spec/filters/bugs/ruby-32.rb +0 -4
- data/spec/filters/bugs/set.rb +10 -2
- data/spec/filters/bugs/singleton.rb +0 -2
- data/spec/filters/bugs/string.rb +140 -1
- data/spec/filters/bugs/struct.rb +15 -5
- data/spec/filters/bugs/time.rb +56 -2
- data/spec/filters/bugs/trace_point.rb +1 -0
- data/spec/filters/bugs/unboundmethod.rb +4 -9
- data/spec/filters/bugs/warnings.rb +0 -1
- data/spec/filters/platform/firefox/exception.rb +3 -3
- data/spec/filters/platform/firefox/kernel.rb +1 -0
- data/spec/filters/platform/safari/exception.rb +2 -2
- data/spec/filters/platform/safari/float.rb +1 -0
- data/spec/filters/platform/safari/kernel.rb +1 -0
- data/spec/filters/platform/safari/literal_regexp.rb +2 -2
- data/spec/filters/unsupported/hash.rb +1 -1
- data/spec/lib/compiler_spec.rb +4 -0
- data/spec/opal/core/class/clone_spec.rb +36 -0
- data/spec/opal/core/module/define_method_spec.rb +29 -0
- data/spec/opal/core/object_id_spec.rb +0 -6
- data/spec/opal/language/predefined_spec.rb +20 -0
- data/spec/opal/language/yield_spec.rb +43 -0
- data/spec/ruby_specs +1 -2
- data/stdlib/bigdecimal.rb +2 -0
- data/stdlib/cgi/util.rb +89 -0
- data/stdlib/cgi.rb +1 -14
- data/stdlib/delegate.rb +3 -4
- data/stdlib/pathname.rb +1 -1
- data/stdlib/promise/v2.rb +22 -7
- data/stdlib/stringio.rb +2 -0
- data/tasks/testing.rake +15 -11
- data/test/opal/promisev2/test_always.rb +14 -0
- data/test/opal/unsupported_and_bugs.rb +0 -8
- metadata +16 -8
data/stdlib/delegate.rb
CHANGED
@@ -52,10 +52,9 @@ class Delegator < BasicObject
|
|
52
52
|
kernel = ::Kernel.dup
|
53
53
|
kernel.class_eval do
|
54
54
|
alias_method :__raise__, :raise
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
# end
|
55
|
+
%i[to_s inspect !~ === <=> hash].each do |m|
|
56
|
+
undef_method m
|
57
|
+
end
|
59
58
|
private_instance_methods.each do |m|
|
60
59
|
if /\Ablock_given\?\z|\Aiterator\?\z|\A__.*__\z/ =~ m
|
61
60
|
next
|
data/stdlib/pathname.rb
CHANGED
data/stdlib/promise/v2.rb
CHANGED
@@ -144,6 +144,7 @@ class PromiseV2 < `Promise`
|
|
144
144
|
`Promise.resolve(#{value})`.tap do |prom|
|
145
145
|
prom.instance_variable_set(:@type, :resolve)
|
146
146
|
prom.instance_variable_set(:@realized, :resolve)
|
147
|
+
prom.instance_variable_set(:@value_set, true)
|
147
148
|
prom.instance_variable_set(:@value, value)
|
148
149
|
end
|
149
150
|
end
|
@@ -152,6 +153,7 @@ class PromiseV2 < `Promise`
|
|
152
153
|
`Promise.reject(#{value})`.tap do |prom|
|
153
154
|
prom.instance_variable_set(:@type, :reject)
|
154
155
|
prom.instance_variable_set(:@realized, :reject)
|
156
|
+
prom.instance_variable_set(:@value_set, true)
|
155
157
|
prom.instance_variable_set(:@value, value)
|
156
158
|
end
|
157
159
|
end
|
@@ -199,6 +201,7 @@ class PromiseV2 < `Promise`
|
|
199
201
|
def resolve(value = nil)
|
200
202
|
nativity_check!
|
201
203
|
raise ArgumentError, 'this promise was already resolved' if @realized
|
204
|
+
@value_set = true
|
202
205
|
@value = value
|
203
206
|
@realized = :resolve
|
204
207
|
@resolve_proc.call(value)
|
@@ -208,6 +211,7 @@ class PromiseV2 < `Promise`
|
|
208
211
|
def reject(value = nil)
|
209
212
|
nativity_check!
|
210
213
|
raise ArgumentError, 'this promise was already resolved' if @realized
|
214
|
+
@value_set = true
|
211
215
|
@value = value
|
212
216
|
@realized = :reject
|
213
217
|
@reject_proc.call(value)
|
@@ -218,6 +222,7 @@ class PromiseV2 < `Promise`
|
|
218
222
|
prom = nil
|
219
223
|
blk = gen_tracing_proc(block) do |val|
|
220
224
|
prom.instance_variable_set(:@realized, :resolve)
|
225
|
+
prom.instance_variable_set(:@value_set, true)
|
221
226
|
prom.instance_variable_set(:@value, val)
|
222
227
|
end
|
223
228
|
prom = `self.then(#{blk})`
|
@@ -236,6 +241,7 @@ class PromiseV2 < `Promise`
|
|
236
241
|
prom = nil
|
237
242
|
blk = gen_tracing_proc(block) do |val|
|
238
243
|
prom.instance_variable_set(:@realized, :resolve)
|
244
|
+
prom.instance_variable_set(:@value_set, true)
|
239
245
|
prom.instance_variable_set(:@value, val)
|
240
246
|
end
|
241
247
|
prom = `self.catch(#{blk})`
|
@@ -254,9 +260,10 @@ class PromiseV2 < `Promise`
|
|
254
260
|
prom = nil
|
255
261
|
blk = gen_tracing_proc(block) do |val|
|
256
262
|
prom.instance_variable_set(:@realized, :resolve)
|
263
|
+
prom.instance_variable_set(:@value_set, true)
|
257
264
|
prom.instance_variable_set(:@value, val)
|
258
265
|
end
|
259
|
-
prom = `self.finally(
|
266
|
+
prom = `self.finally(function() { return blk(self.$value_internal()); })`
|
260
267
|
prom.instance_variable_set(:@prev, self)
|
261
268
|
prom.instance_variable_set(:@type, :always)
|
262
269
|
(@next ||= []) << prom
|
@@ -312,11 +319,7 @@ class PromiseV2 < `Promise`
|
|
312
319
|
|
313
320
|
def value
|
314
321
|
if resolved?
|
315
|
-
|
316
|
-
@value.value
|
317
|
-
else
|
318
|
-
@value
|
319
|
-
end
|
322
|
+
value_internal
|
320
323
|
end
|
321
324
|
end
|
322
325
|
|
@@ -366,7 +369,7 @@ class PromiseV2 < `Promise`
|
|
366
369
|
result += " >> #{@next.inspect}"
|
367
370
|
end
|
368
371
|
|
369
|
-
result += ": #{
|
372
|
+
result += ": #{value.inspect}"
|
370
373
|
result += '>'
|
371
374
|
|
372
375
|
result
|
@@ -386,4 +389,16 @@ class PromiseV2 < `Promise`
|
|
386
389
|
alias resolve! resolve
|
387
390
|
alias to_n itself
|
388
391
|
alias to_v2 itself
|
392
|
+
|
393
|
+
private
|
394
|
+
|
395
|
+
def value_internal
|
396
|
+
if PromiseV2 === @value
|
397
|
+
@value.value
|
398
|
+
elsif @value_set
|
399
|
+
@value
|
400
|
+
elsif @prev
|
401
|
+
@prev.value
|
402
|
+
end
|
403
|
+
end
|
389
404
|
end
|
data/stdlib/stringio.rb
CHANGED
data/tasks/testing.rake
CHANGED
@@ -36,6 +36,7 @@ module Testing
|
|
36
36
|
mspec/commands/mspec-run
|
37
37
|
etc
|
38
38
|
rubygems
|
39
|
+
zlib
|
39
40
|
]
|
40
41
|
end
|
41
42
|
|
@@ -334,7 +335,6 @@ platforms.each do |platform|
|
|
334
335
|
includes = "-Itest/cruby/test"
|
335
336
|
files = %w[
|
336
337
|
benchmark/test_benchmark.rb
|
337
|
-
ruby/test_call.rb
|
338
338
|
opal/test_keyword.rb
|
339
339
|
opal/test_base64.rb
|
340
340
|
opal/test_openuri.rb
|
@@ -427,17 +427,21 @@ task :smoke_test do
|
|
427
427
|
begin
|
428
428
|
require 'rspec/expectations'
|
429
429
|
extend RSpec::Matchers
|
430
|
-
expect(actual_output.lines[0]).to eq("
|
431
|
-
expect(actual_output.lines[1]).to eq("\n")
|
432
|
-
expect(actual_output.lines[2]).to
|
433
|
-
expect(actual_output.lines[
|
434
|
-
expect(actual_output.lines[
|
435
|
-
|
436
|
-
expect(actual_output.lines[
|
437
|
-
expect(actual_output.lines[
|
430
|
+
expect(actual_output.lines[0]).to eq("\n")
|
431
|
+
expect(actual_output.lines[1]).to eq("Opal::Deprecations\n")
|
432
|
+
expect(actual_output.lines[2]).to eq("\e[32m defaults to warn\e[0m\n")
|
433
|
+
expect(actual_output.lines[3]).to eq("\e[32m can be set to raise\e[0m\n")
|
434
|
+
expect(actual_output.lines[4]).to eq("\n")
|
435
|
+
|
436
|
+
expect(actual_output.lines[5]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
|
437
|
+
expect(actual_output.lines[7]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:7\n})
|
438
|
+
expect(actual_output.lines[9]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:12\n})
|
439
|
+
expect(actual_output.lines[10]).to eq("\n")
|
440
|
+
expect(actual_output.lines[11]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
|
441
|
+
expect(actual_output.lines[12]).to eq("[32m2 examples, 0 failures[0m\n")
|
438
442
|
expect([
|
439
|
-
actual_output.lines[
|
440
|
-
actual_output.lines[
|
443
|
+
actual_output.lines[6],
|
444
|
+
actual_output.lines[8],
|
441
445
|
]).to contain_exactly(
|
442
446
|
" Opal::Deprecations defaults to warn\n",
|
443
447
|
" Opal::Deprecations can be set to raise\n",
|
@@ -60,4 +60,18 @@ class TestPromiseAlways < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
assert_raise(ArgumentError) { p.always! {} }
|
62
62
|
end
|
63
|
+
|
64
|
+
def test_gets_the_value_from_the_previous_successful_block
|
65
|
+
PromiseV2.value(23)
|
66
|
+
.then { 123 }
|
67
|
+
.rescue { 234 }
|
68
|
+
.always { |v| assert_equal(123, v) }
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_gets_the_value_from_the_previous_rescued_block
|
72
|
+
PromiseV2.reject(23)
|
73
|
+
.then { 123 }
|
74
|
+
.rescue { 234 }
|
75
|
+
.always { |v| assert_equal(234, v) }
|
76
|
+
end
|
63
77
|
end
|
@@ -30,14 +30,6 @@ class TestBase64
|
|
30
30
|
bug :test_urlsafe_decode64_unpadded
|
31
31
|
end
|
32
32
|
|
33
|
-
class TestCall
|
34
|
-
# They work fine if `"a".sub! "b"` is replaced by `[].slice 1`
|
35
|
-
unsupported :test_safe_call_block_command
|
36
|
-
unsupported :test_safe_call_block_call
|
37
|
-
unsupported :test_safe_call_block_call_brace
|
38
|
-
unsupported :test_safe_call_block_call_command
|
39
|
-
end
|
40
|
-
|
41
33
|
class TestBenchmark
|
42
34
|
# sleep is unsupported if not awaited
|
43
35
|
unsupported :test_realtime_output
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.0
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ast
|
@@ -706,6 +706,7 @@ files:
|
|
706
706
|
- spec/filters/bugs/basicobject.rb
|
707
707
|
- spec/filters/bugs/bigdecimal.rb
|
708
708
|
- spec/filters/bugs/binding.rb
|
709
|
+
- spec/filters/bugs/cgi.rb
|
709
710
|
- spec/filters/bugs/class.rb
|
710
711
|
- spec/filters/bugs/complex.rb
|
711
712
|
- spec/filters/bugs/date.rb
|
@@ -737,6 +738,7 @@ files:
|
|
737
738
|
- spec/filters/bugs/random.rb
|
738
739
|
- spec/filters/bugs/range.rb
|
739
740
|
- spec/filters/bugs/rational.rb
|
741
|
+
- spec/filters/bugs/refinement.rb
|
740
742
|
- spec/filters/bugs/regexp.rb
|
741
743
|
- spec/filters/bugs/ruby-32.rb
|
742
744
|
- spec/filters/bugs/set.rb
|
@@ -853,6 +855,7 @@ files:
|
|
853
855
|
- spec/opal/core/array/uniq_spec.rb
|
854
856
|
- spec/opal/core/array/zip_spec.rb
|
855
857
|
- spec/opal/core/boolean_spec.rb
|
858
|
+
- spec/opal/core/class/clone_spec.rb
|
856
859
|
- spec/opal/core/class/inherited_spec.rb
|
857
860
|
- spec/opal/core/enumerable/all_break_spec.rb
|
858
861
|
- spec/opal/core/enumerable/any_break_spec.rb
|
@@ -922,6 +925,7 @@ files:
|
|
922
925
|
- spec/opal/core/language_spec.rb
|
923
926
|
- spec/opal/core/marshal/dump_spec.rb
|
924
927
|
- spec/opal/core/marshal/load_spec.rb
|
928
|
+
- spec/opal/core/module/define_method_spec.rb
|
925
929
|
- spec/opal/core/module_spec.rb
|
926
930
|
- spec/opal/core/number/to_i_spec.rb
|
927
931
|
- spec/opal/core/number/to_s_spec.rb
|
@@ -951,6 +955,8 @@ files:
|
|
951
955
|
- spec/opal/core/string_spec.rb
|
952
956
|
- spec/opal/core/struct/dup_spec.rb
|
953
957
|
- spec/opal/core/time_spec.rb
|
958
|
+
- spec/opal/language/predefined_spec.rb
|
959
|
+
- spec/opal/language/yield_spec.rb
|
954
960
|
- spec/opal/stdlib/erb/erb_spec.rb
|
955
961
|
- spec/opal/stdlib/erb/inline_block.opalerb
|
956
962
|
- spec/opal/stdlib/erb/quoted.opalerb
|
@@ -1009,6 +1015,7 @@ files:
|
|
1009
1015
|
- stdlib/buffer/array.rb
|
1010
1016
|
- stdlib/buffer/view.rb
|
1011
1017
|
- stdlib/cgi.rb
|
1018
|
+
- stdlib/cgi/util.rb
|
1012
1019
|
- stdlib/console.rb
|
1013
1020
|
- stdlib/date.rb
|
1014
1021
|
- stdlib/date/date_time.rb
|
@@ -1221,10 +1228,10 @@ licenses:
|
|
1221
1228
|
metadata:
|
1222
1229
|
homepage_uri: https://opalrb.com/
|
1223
1230
|
bug_tracker_uri: https://github.com/opal/opal/issues
|
1224
|
-
changelog_uri: https://github.com/opal/opal/blob/v1.8.0
|
1225
|
-
readme_uri: https://github.com/opal/opal/blob/v1.8.0
|
1226
|
-
api_documentation_uri: http://opalrb.com/docs/api/v1.8.0
|
1227
|
-
guides_uri: http://opalrb.com/docs/guides/v1.8.0
|
1231
|
+
changelog_uri: https://github.com/opal/opal/blob/v1.8.0/CHANGELOG.md
|
1232
|
+
readme_uri: https://github.com/opal/opal/blob/v1.8.0/README.md
|
1233
|
+
api_documentation_uri: http://opalrb.com/docs/api/v1.8.0/index.html
|
1234
|
+
guides_uri: http://opalrb.com/docs/guides/v1.8.0/index.html
|
1228
1235
|
chat_uri: https://gitter.im/opal/opal
|
1229
1236
|
source_code_uri: https://github.com/opal/opal
|
1230
1237
|
post_install_message:
|
@@ -1238,9 +1245,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1238
1245
|
version: '2.3'
|
1239
1246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1240
1247
|
requirements:
|
1241
|
-
- - "
|
1248
|
+
- - ">="
|
1242
1249
|
- !ruby/object:Gem::Version
|
1243
|
-
version:
|
1250
|
+
version: '0'
|
1244
1251
|
requirements: []
|
1245
1252
|
rubygems_version: 3.4.5
|
1246
1253
|
signing_key:
|
@@ -1703,6 +1710,7 @@ test_files:
|
|
1703
1710
|
- stdlib/buffer/array.rb
|
1704
1711
|
- stdlib/buffer/view.rb
|
1705
1712
|
- stdlib/cgi.rb
|
1713
|
+
- stdlib/cgi/util.rb
|
1706
1714
|
- stdlib/console.rb
|
1707
1715
|
- stdlib/date.rb
|
1708
1716
|
- stdlib/date/date_time.rb
|