opal 1.3.2 → 1.4.0.alpha1
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/.github/workflows/build.yml +0 -3
- data/.rubocop.yml +5 -1
- data/UNRELEASED.md +66 -2
- data/benchmark-ips/bm_truthy.rb +30 -0
- data/bin/opal-mspec +1 -3
- data/bin/opal-repl +1 -2
- data/bin/remove-filters +1 -4
- data/docs/compiled_ruby.md +10 -6
- data/exe/opal-repl +1 -3
- data/lib/opal/ast/builder.rb +1 -1
- data/lib/opal/cli.rb +2 -2
- data/lib/opal/cli_runners/nodejs.rb +9 -2
- data/lib/opal/cli_runners/source-map-support-browser.js +80 -216
- data/lib/opal/cli_runners/source-map-support-node.js +80 -216
- data/lib/opal/cli_runners/source-map-support.js +5 -1
- data/lib/opal/cli_runners/system_runner.rb +10 -4
- data/lib/opal/compiler.rb +3 -5
- data/lib/opal/fragment.rb +5 -1
- data/lib/opal/nodes/args/extract_block_arg.rb +1 -8
- data/lib/opal/nodes/args/extract_kwoptarg.rb +1 -3
- data/lib/opal/nodes/args/extract_optarg.rb +1 -3
- data/lib/opal/nodes/args/extract_post_arg.rb +2 -5
- data/lib/opal/nodes/args/extract_post_optarg.rb +2 -7
- data/lib/opal/nodes/args/initialize_iterarg.rb +1 -3
- data/lib/opal/nodes/args/prepare_post_args.rb +5 -1
- data/lib/opal/nodes/base.rb +3 -2
- data/lib/opal/nodes/call.rb +20 -9
- data/lib/opal/nodes/call_special.rb +50 -0
- data/lib/opal/nodes/class.rb +24 -15
- data/lib/opal/nodes/constants.rb +23 -5
- data/lib/opal/nodes/def.rb +20 -23
- data/lib/opal/nodes/defined.rb +5 -5
- data/lib/opal/nodes/definitions.rb +2 -2
- data/lib/opal/nodes/defs.rb +2 -5
- data/lib/opal/nodes/helpers.rb +48 -18
- data/lib/opal/nodes/if.rb +109 -8
- data/lib/opal/nodes/iter.rb +23 -16
- data/lib/opal/nodes/literal.rb +18 -4
- data/lib/opal/nodes/logic.rb +2 -1
- data/lib/opal/nodes/masgn.rb +4 -9
- data/lib/opal/nodes/module.rb +29 -19
- data/lib/opal/nodes/node_with_args.rb +1 -7
- data/lib/opal/nodes/scope.rb +54 -15
- data/lib/opal/nodes/singleton_class.rb +5 -3
- data/lib/opal/nodes/super.rb +3 -3
- data/lib/opal/nodes/top.rb +34 -31
- data/lib/opal/nodes/variables.rb +2 -2
- data/lib/opal/nodes/x_string.rb +3 -0
- data/lib/opal/nodes.rb +0 -1
- data/lib/opal/parser/patch.rb +75 -0
- data/lib/opal/parser/with_ruby_lexer.rb +1 -1
- data/lib/opal/regexp_anchors.rb +7 -7
- data/lib/opal/requires.rb +19 -0
- data/lib/opal/rewriters/pattern_matching.rb +1 -1
- data/lib/opal/rewriters/returnable_logic.rb +102 -4
- data/lib/opal/util.rb +2 -2
- data/lib/opal/version.rb +1 -1
- data/lib/opal.rb +1 -17
- data/opal/corelib/array/pack.rb +11 -11
- data/opal/corelib/array.rb +193 -152
- data/opal/corelib/basic_object.rb +14 -14
- data/opal/corelib/binding.rb +7 -7
- data/opal/corelib/boolean.rb +12 -15
- data/opal/corelib/class.rb +23 -1
- data/opal/corelib/comparable.rb +8 -8
- data/opal/corelib/complex/base.rb +2 -2
- data/opal/corelib/complex.rb +79 -88
- data/opal/corelib/constants.rb +9 -9
- data/opal/corelib/dir.rb +4 -3
- data/opal/corelib/enumerable.rb +140 -127
- data/opal/corelib/enumerator/arithmetic_sequence.rb +177 -0
- data/opal/corelib/enumerator/chain.rb +42 -0
- data/opal/corelib/enumerator/generator.rb +35 -0
- data/opal/corelib/enumerator/lazy.rb +243 -0
- data/opal/corelib/enumerator/yielder.rb +36 -0
- data/opal/corelib/enumerator.rb +45 -300
- data/opal/corelib/error/errno.rb +47 -0
- data/opal/corelib/error.rb +62 -60
- data/opal/corelib/file.rb +26 -12
- data/opal/corelib/hash.rb +98 -107
- data/opal/corelib/helpers.rb +62 -13
- data/opal/corelib/io.rb +47 -34
- data/opal/corelib/kernel/format.rb +29 -29
- data/opal/corelib/kernel.rb +86 -83
- data/opal/corelib/main.rb +14 -12
- data/opal/corelib/marshal/read_buffer.rb +15 -15
- data/opal/corelib/marshal/write_buffer.rb +45 -44
- data/opal/corelib/marshal.rb +3 -3
- data/opal/corelib/math.rb +50 -50
- data/opal/corelib/method.rb +12 -8
- data/opal/corelib/module.rb +96 -79
- data/opal/corelib/nil.rb +9 -11
- data/opal/corelib/number.rb +113 -118
- data/opal/corelib/numeric.rb +37 -33
- data/opal/corelib/object_space.rb +11 -10
- data/opal/corelib/pack_unpack/format_string_parser.rb +3 -3
- data/opal/corelib/pattern_matching/base.rb +7 -7
- data/opal/corelib/pattern_matching.rb +1 -1
- data/opal/corelib/proc.rb +15 -16
- data/opal/corelib/process/base.rb +2 -2
- data/opal/corelib/process/status.rb +21 -0
- data/opal/corelib/process.rb +5 -5
- data/opal/corelib/random/formatter.rb +11 -11
- data/opal/corelib/random/math_random.js.rb +1 -1
- data/opal/corelib/random/mersenne_twister.rb +3 -3
- data/opal/corelib/random/seedrandom.js.rb +3 -3
- data/opal/corelib/random.rb +17 -17
- data/opal/corelib/range.rb +51 -35
- data/opal/corelib/rational/base.rb +4 -4
- data/opal/corelib/rational.rb +61 -62
- data/opal/corelib/regexp.rb +47 -38
- data/opal/corelib/runtime.js +245 -139
- data/opal/corelib/string/encoding.rb +21 -21
- data/opal/corelib/string/unpack.rb +19 -14
- data/opal/corelib/string.rb +135 -128
- data/opal/corelib/struct.rb +59 -46
- data/opal/corelib/time.rb +47 -57
- data/opal/corelib/trace_point.rb +2 -2
- data/opal/corelib/unsupported.rb +31 -120
- data/opal/corelib/variables.rb +3 -3
- data/opal/opal/base.rb +9 -8
- data/opal/opal/full.rb +8 -8
- data/opal/opal/mini.rb +17 -17
- data/opal/opal.rb +17 -18
- data/opal.gemspec +1 -1
- data/spec/filters/bugs/array.rb +4 -24
- data/spec/filters/bugs/bigdecimal.rb +0 -23
- data/spec/filters/bugs/binding.rb +0 -1
- data/spec/filters/bugs/boolean.rb +3 -0
- data/spec/filters/bugs/class.rb +2 -0
- data/spec/filters/bugs/date.rb +0 -5
- data/spec/filters/bugs/encoding.rb +8 -50
- data/spec/filters/bugs/enumerable.rb +4 -1
- data/spec/filters/bugs/enumerator.rb +3 -36
- data/spec/filters/bugs/exception.rb +0 -2
- data/spec/filters/bugs/file.rb +0 -2
- data/spec/filters/bugs/float.rb +0 -3
- data/spec/filters/bugs/hash.rb +5 -3
- data/spec/filters/bugs/integer.rb +2 -3
- data/spec/filters/bugs/kernel.rb +2 -31
- data/spec/filters/bugs/language.rb +29 -49
- data/spec/filters/bugs/main.rb +0 -2
- data/spec/filters/bugs/marshal.rb +2 -3
- data/spec/filters/bugs/matrix.rb +0 -36
- data/spec/filters/bugs/module.rb +7 -61
- data/spec/filters/bugs/numeric.rb +0 -7
- data/spec/filters/bugs/objectspace.rb +1 -1
- data/spec/filters/bugs/pack_unpack.rb +0 -4
- data/spec/filters/bugs/proc.rb +0 -9
- data/spec/filters/bugs/random.rb +0 -5
- data/spec/filters/bugs/range.rb +1 -6
- data/spec/filters/bugs/regexp.rb +0 -3
- data/spec/filters/bugs/set.rb +8 -1
- data/spec/filters/bugs/string.rb +9 -34
- data/spec/filters/bugs/stringscanner.rb +8 -7
- data/spec/filters/bugs/struct.rb +2 -3
- data/spec/filters/bugs/symbol.rb +0 -1
- data/spec/filters/bugs/time.rb +0 -8
- data/spec/filters/bugs/unboundmethod.rb +0 -8
- data/spec/filters/bugs/warnings.rb +1 -7
- data/spec/filters/unsupported/freeze.rb +24 -0
- data/spec/filters/unsupported/integer.rb +1 -0
- data/spec/filters/unsupported/kernel.rb +12 -0
- data/spec/filters/unsupported/privacy.rb +3 -0
- data/spec/filters/unsupported/string.rb +2 -0
- data/spec/lib/builder_spec.rb +2 -2
- data/spec/lib/cli_spec.rb +1 -1
- data/spec/lib/compiler_spec.rb +37 -37
- data/spec/lib/simple_server_spec.rb +2 -2
- data/spec/lib/source_map/file_spec.rb +1 -1
- data/spec/opal/compiler/irb_spec.rb +2 -2
- data/spec/opal/core/kernel/puts_spec.rb +90 -0
- data/spec/opal/core/language/super_spec.rb +24 -0
- data/spec/ruby_specs +4 -2
- data/spec/support/rewriters_helper.rb +1 -1
- data/stdlib/bigdecimal.rb +7 -11
- data/stdlib/buffer/view.rb +2 -2
- data/stdlib/buffer.rb +2 -2
- data/stdlib/date.rb +5 -6
- data/stdlib/erb.rb +1 -0
- data/stdlib/js.rb +2 -1
- data/stdlib/native.rb +7 -8
- data/stdlib/nodejs/argf.rb +4 -4
- data/stdlib/nodejs/base.rb +29 -0
- data/stdlib/nodejs/dir.rb +1 -1
- data/stdlib/nodejs/env.rb +6 -9
- data/stdlib/nodejs/file.rb +23 -17
- data/stdlib/nodejs/fileutils.rb +3 -3
- data/stdlib/nodejs/io.rb +2 -20
- data/stdlib/nodejs/irb.rb +0 -0
- data/stdlib/nodejs/kernel.rb +2 -37
- data/stdlib/nodejs.rb +1 -3
- data/stdlib/opal/miniracer.rb +2 -0
- data/stdlib/opal/platform.rb +6 -13
- data/stdlib/opal/replutils.rb +16 -5
- data/stdlib/opal-parser.rb +2 -2
- data/stdlib/optparse/ac.rb +54 -0
- data/stdlib/optparse/date.rb +14 -0
- data/stdlib/optparse/kwargs.rb +22 -0
- data/stdlib/optparse/shellwords.rb +7 -0
- data/stdlib/optparse/time.rb +15 -0
- data/stdlib/optparse/uri.rb +7 -0
- data/stdlib/optparse/version.rb +69 -0
- data/stdlib/optparse.rb +2279 -0
- data/stdlib/pathname.rb +5 -6
- data/stdlib/pp.rb +18 -2
- data/stdlib/promise/v2.rb +18 -22
- data/stdlib/promise.rb +15 -21
- data/stdlib/set.rb +32 -32
- data/stdlib/shellwords.rb +240 -0
- data/stdlib/stringio.rb +3 -6
- data/stdlib/strscan.rb +5 -8
- data/stdlib/template.rb +2 -2
- data/stdlib/thread.rb +7 -9
- data/tasks/performance.rake +5 -2
- data/tasks/testing/mspec_special_calls.rb +0 -12
- data/tasks/testing.rake +55 -37
- data/test/nodejs/test_file.rb +11 -0
- metadata +55 -10
- data/lib/opal/nodes/case.rb +0 -114
data/stdlib/strscan.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class StringScanner
|
2
|
-
attr_reader :pos
|
3
|
-
attr_reader :matched
|
2
|
+
attr_reader :pos, :matched
|
4
3
|
|
5
4
|
def initialize(string)
|
6
5
|
@string = string
|
@@ -16,8 +15,6 @@ class StringScanner
|
|
16
15
|
`#{@pos} === 0 || #{@string}.charAt(#{@pos} - 1) === "\n"`
|
17
16
|
end
|
18
17
|
|
19
|
-
alias bol? beginning_of_line?
|
20
|
-
|
21
18
|
def scan(pattern)
|
22
19
|
pattern = anchor(pattern)
|
23
20
|
|
@@ -91,7 +88,7 @@ class StringScanner
|
|
91
88
|
when String
|
92
89
|
# noop
|
93
90
|
else
|
94
|
-
idx = Opal.coerce_to!(idx, Integer, :to_int)
|
91
|
+
idx = ::Opal.coerce_to!(idx, Integer, :to_int)
|
95
92
|
end
|
96
93
|
%x{
|
97
94
|
var match = #{@match};
|
@@ -227,9 +224,6 @@ class StringScanner
|
|
227
224
|
}
|
228
225
|
end
|
229
226
|
|
230
|
-
# not exactly, but for now...
|
231
|
-
alias getch get_byte
|
232
|
-
|
233
227
|
def match?(pattern)
|
234
228
|
pattern = anchor(pattern)
|
235
229
|
|
@@ -319,6 +313,9 @@ class StringScanner
|
|
319
313
|
self
|
320
314
|
end
|
321
315
|
|
316
|
+
alias bol? beginning_of_line?
|
317
|
+
alias getch get_byte # not exactly the same, but for now...
|
318
|
+
|
322
319
|
private
|
323
320
|
|
324
321
|
def anchor(pattern)
|
data/stdlib/template.rb
CHANGED
data/stdlib/thread.rb
CHANGED
@@ -66,7 +66,7 @@ class Thread
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def coerce_key_name(key)
|
69
|
-
Opal.coerce_to!(key, String, :to_s)
|
69
|
+
::Opal.coerce_to!(key, String, :to_s)
|
70
70
|
end
|
71
71
|
|
72
72
|
class Queue
|
@@ -86,8 +86,6 @@ class Thread
|
|
86
86
|
@storage.size
|
87
87
|
end
|
88
88
|
|
89
|
-
alias length size
|
90
|
-
|
91
89
|
def pop(non_block = false)
|
92
90
|
if empty?
|
93
91
|
raise ThreadError, 'Queue empty' if non_block
|
@@ -97,19 +95,19 @@ class Thread
|
|
97
95
|
@storage.shift
|
98
96
|
end
|
99
97
|
|
100
|
-
alias shift pop
|
101
|
-
alias deq pop
|
102
|
-
|
103
98
|
def push(value)
|
104
99
|
@storage.push(value)
|
105
100
|
end
|
106
101
|
|
107
|
-
alias << push
|
108
|
-
alias enq push
|
109
|
-
|
110
102
|
def each(&block)
|
111
103
|
@storage.each(&block)
|
112
104
|
end
|
105
|
+
|
106
|
+
alias << push
|
107
|
+
alias deq pop
|
108
|
+
alias enq push
|
109
|
+
alias length size
|
110
|
+
alias shift pop
|
113
111
|
end
|
114
112
|
|
115
113
|
class Backtrace
|
data/tasks/performance.rake
CHANGED
@@ -74,12 +74,14 @@ performance_stat = ->(name) {
|
|
74
74
|
stat[:compiler_time] = mean_time.(tries: 7) { sh(ASCIIDOCTOR_BUILD_OPAL) }
|
75
75
|
|
76
76
|
puts "\n* Running AsciiDoctor with #{name}..."
|
77
|
-
stat[:run_time] = mean_time.(tries:
|
77
|
+
stat[:run_time] = mean_time.(tries: 63) { sh("#{ASCIIDOCTOR_RUN_OPAL} > tmp/performance/opal_result_#{name}.html") }
|
78
78
|
stat[:correct] = File.read("tmp/performance/opal_result_#{name}.html") == File.read("tmp/performance/ruby_result.html")
|
79
79
|
stat[:size] = File.size("tmp/performance/asciidoctor_test.js")
|
80
80
|
|
81
81
|
puts "\n* Minifying AsciiDoctor with #{name}..."
|
82
|
-
|
82
|
+
source = File.read("tmp/performance/asciidoctor_test.js")
|
83
|
+
stat[:min_size] = Opal::Util.uglify(source).bytesize rescue Float::INFINITY
|
84
|
+
stat[:min_size_m] = Opal::Util.uglify(source, mangle: true).bytesize rescue Float::INFINITY
|
83
85
|
|
84
86
|
stat
|
85
87
|
}
|
@@ -132,6 +134,7 @@ namespace :performance do
|
|
132
134
|
compare_values.("Run time", current[:run_time], previous[:run_time])
|
133
135
|
compare_values.("Bundle size", current[:size], previous[:size])
|
134
136
|
compare_values.("Minified bundle size", current[:min_size], previous[:min_size])
|
137
|
+
compare_values.("Mangled & minified", current[:min_size_m], previous[:min_size_m])
|
135
138
|
|
136
139
|
if failed
|
137
140
|
puts "--- Failures ---"
|
@@ -58,17 +58,5 @@ def opal_unsupported_filter(filter_name, &block)
|
|
58
58
|
Opal::Rubyspec::FiltersRewriter.instance_eval(&block)
|
59
59
|
end
|
60
60
|
|
61
|
-
# In the test environment we have to parse invalid characters
|
62
|
-
# Otherwise the parser throws an error and the whole suites aborts
|
63
|
-
class Opal::AST::Builder
|
64
|
-
def string_value(token)
|
65
|
-
unless token[0].valid_encoding?
|
66
|
-
diagnostic(:warning, :invalid_encoding, nil, token[1])
|
67
|
-
end
|
68
|
-
|
69
|
-
token[0]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
61
|
Dir[File.expand_path('../../../spec/filters/unsupported/**/*.rb', __FILE__)].each { |f| require f }
|
74
62
|
Dir[File.expand_path('../../../spec/filters/bugs/**/*.rb', __FILE__)].each { |f| require f }
|
data/tasks/testing.rake
CHANGED
@@ -284,15 +284,23 @@ Use PATTERN environment variable to manually set the glob for specs:
|
|
284
284
|
bundle exec rake mspec_nodejs PATTERN=spec/ruby/core/numeric/**_spec.rb
|
285
285
|
DESC
|
286
286
|
|
287
|
-
platforms = %w[nodejs server chrome gjs quickjs]
|
287
|
+
platforms = %w[nodejs opalopal_nodejs server chrome gjs quickjs]
|
288
|
+
node_platforms = %w[nodejs opalopal_nodejs]
|
288
289
|
mspec_suites = %w[ruby opal]
|
289
290
|
minitest_suites = %w[cruby]
|
290
291
|
|
292
|
+
require 'opal/paths'
|
293
|
+
opalopal_cmdline = "-sreadline -rnodejs -rcorelib/string/unpack -popal/cli_runners/nodejs exe/opal -- #{Opal.paths.map{|i| "-I#{i}"}.join(" ")} --no-source-map "
|
294
|
+
|
291
295
|
platforms.each do |platform|
|
292
296
|
mspec_suites.each do |suite|
|
293
297
|
desc "Run the MSpec test suite on Opal::Builder/#{platform}" + pattern_usage
|
294
298
|
task :"mspec_#{suite}_#{platform}" do
|
295
299
|
filename = "tmp/mspec_#{platform}.rb"
|
300
|
+
if platform.start_with? "opalopal_"
|
301
|
+
platform = platform.split('_').last
|
302
|
+
cmdline = opalopal_cmdline
|
303
|
+
end
|
296
304
|
mkdir_p File.dirname(filename)
|
297
305
|
bm_filepath = Testing::MSpec.bm_filepath if ENV['BM']
|
298
306
|
specs_env = {
|
@@ -306,7 +314,7 @@ platforms.each do |platform|
|
|
306
314
|
stubs = Testing::MSpec.stubs.map{|s| "-s#{s}"}.join(' ')
|
307
315
|
|
308
316
|
sh "ruby -w -rbundler/setup -r#{__dir__}/testing/mspec_special_calls "\
|
309
|
-
"exe/opal -Ispec/mspec/lib -Ispec -Ilib #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}"
|
317
|
+
"exe/opal #{cmdline} -Ispec/mspec/lib -Ispec -Ilib #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}"
|
310
318
|
|
311
319
|
if bm_filepath
|
312
320
|
puts "Benchmark results have been written to #{bm_filepath}"
|
@@ -342,6 +350,10 @@ platforms.each do |platform|
|
|
342
350
|
end
|
343
351
|
Testing::HTTPServer.new.with_server do |session|
|
344
352
|
filename = "tmp/minitest_#{suite}_#{platform}.rb"
|
353
|
+
if platform.start_with? "opalopal_"
|
354
|
+
platform = platform.split('_').last
|
355
|
+
cmdline = opalopal_cmdline
|
356
|
+
end
|
345
357
|
files.push('nodejs') if platform == 'nodejs'
|
346
358
|
Testing::Minitest.write_file(filename, files, ENV)
|
347
359
|
|
@@ -349,39 +361,44 @@ platforms.each do |platform|
|
|
349
361
|
includes = "-Itest -Ilib -Ivendored-minitest #{includes}"
|
350
362
|
|
351
363
|
sh "ruby -rbundler/setup "\
|
352
|
-
"exe/opal #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}"
|
364
|
+
"exe/opal #{cmdline} #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location #{filename}"
|
353
365
|
end
|
354
366
|
end
|
355
367
|
end
|
356
368
|
end
|
357
369
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
platform
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
370
|
+
node_platforms.each do |platform|
|
371
|
+
# The name ends with the platform, which is of course mandated in this case
|
372
|
+
desc "Run the Node.js Minitest suite on #{platform}"
|
373
|
+
task :"minitest_node_#{platform}" do
|
374
|
+
if platform.start_with? "opalopal_"
|
375
|
+
platform = platform.split('_').last
|
376
|
+
cmdline = opalopal_cmdline
|
377
|
+
end
|
378
|
+
files = %w[
|
379
|
+
nodejs
|
380
|
+
opal-parser
|
381
|
+
nodejs/test_dir.rb
|
382
|
+
nodejs/test_env.rb
|
383
|
+
nodejs/test_error.rb
|
384
|
+
nodejs/test_file.rb
|
385
|
+
nodejs/test_file_encoding.rb
|
386
|
+
nodejs/test_io.rb
|
387
|
+
nodejs/test_opal_builder.rb
|
388
|
+
nodejs/test_string.rb
|
389
|
+
nodejs/test_await.rb
|
390
|
+
]
|
391
|
+
|
392
|
+
filename = "tmp/minitest_node_nodejs.rb"
|
393
|
+
Testing::Minitest.write_file(filename, files, ENV)
|
394
|
+
|
395
|
+
stubs = "-soptparse -sio/console -stimeout -smutex_m -srubygems -stempfile -smonitor"
|
396
|
+
includes = "-Itest -Ilib -Ivendored-minitest"
|
397
|
+
|
398
|
+
use_strict_opt = ENV['USE_STRICT'] ? ' --use-strict' : ''
|
399
|
+
sh "ruby -rbundler/setup "\
|
400
|
+
"exe/opal #{cmdline} #{includes} #{stubs} -R#{platform} -Dwarning -A --enable-source-location#{use_strict_opt} #{filename}"
|
401
|
+
end
|
385
402
|
end
|
386
403
|
|
387
404
|
desc 'Run smoke tests with opal-rspec to see if something is broken'
|
@@ -408,13 +425,14 @@ task :smoke_test do
|
|
408
425
|
require 'rspec/expectations'
|
409
426
|
extend RSpec::Matchers
|
410
427
|
expect(actual_output.lines[0]).to eq("[32m.[0m[32m.[0m\n")
|
411
|
-
expect(actual_output.lines[1]).to
|
412
|
-
expect(actual_output.lines[2]).to
|
413
|
-
expect(actual_output.lines[3]).to eq("\n")
|
414
|
-
expect(actual_output.lines[4]).to
|
415
|
-
expect(actual_output.lines[5]).to
|
416
|
-
expect(actual_output.lines[6]).to
|
417
|
-
expect(actual_output.lines[7]).to
|
428
|
+
expect(actual_output.lines[1]).to eq("\n")
|
429
|
+
expect(actual_output.lines[2]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
|
430
|
+
expect(actual_output.lines[3]).to eq("[32m2 examples, 0 failures[0m\n")
|
431
|
+
expect(actual_output.lines[4]).to eq("\n")
|
432
|
+
expect(actual_output.lines[5]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
|
433
|
+
expect(actual_output.lines[6]).to eq(" Opal::Deprecations defaults to warn\n")
|
434
|
+
expect(actual_output.lines[7]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m \n})
|
435
|
+
expect(actual_output.lines[8]).to eq(" Opal::Deprecations can be set to raise\n")
|
418
436
|
rescue RSpec::Expectations::ExpectationNotMetError
|
419
437
|
warn $!.message
|
420
438
|
warn "\n\n== Full output:\n#{actual_output}"
|
data/test/nodejs/test_file.rb
CHANGED
@@ -202,5 +202,16 @@ class TestNodejsFile < Test::Unit::TestCase
|
|
202
202
|
|
203
203
|
def test_join
|
204
204
|
assert_equal('usr/bin', File.join('usr', 'bin'))
|
205
|
+
assert_equal('//a/b', File.join('//a', 'b'))
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_join_supports_any_number_of_arguments
|
209
|
+
assert_equal("a/b/c/d", File.join("a", "b", "c", "d"))
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_join_handles_leading_parts_edge_cases
|
213
|
+
assert_equal("/bin", File.join("/bin"))
|
214
|
+
assert_equal("/bin", File.join("/", "bin"))
|
215
|
+
assert_equal("/bin", File.join("/", "/bin"))
|
205
216
|
end
|
206
217
|
end
|
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.
|
4
|
+
version: 1.4.0.alpha1
|
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: 2021-
|
13
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ast
|
@@ -33,6 +33,9 @@ dependencies:
|
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '3.0'
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 3.0.3.2
|
36
39
|
type: :runtime
|
37
40
|
prerelease: false
|
38
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -40,6 +43,9 @@ dependencies:
|
|
40
43
|
- - "~>"
|
41
44
|
- !ruby/object:Gem::Version
|
42
45
|
version: '3.0'
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.0.3.2
|
43
49
|
- !ruby/object:Gem::Dependency
|
44
50
|
name: sourcemap
|
45
51
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,6 +277,7 @@ files:
|
|
271
277
|
- benchmark-ips/bm_is_number.rb
|
272
278
|
- benchmark-ips/bm_js_symbols_vs_strings.rb
|
273
279
|
- benchmark-ips/bm_symbol_to_proc.rb
|
280
|
+
- benchmark-ips/bm_truthy.rb
|
274
281
|
- benchmark-ips/bm_while_true_vs_loop.rb
|
275
282
|
- benchmark-ips/class_shovel_vs_singleton_class.rb
|
276
283
|
- benchmark/benchmarks
|
@@ -521,7 +528,6 @@ files:
|
|
521
528
|
- lib/opal/nodes/base.rb
|
522
529
|
- lib/opal/nodes/call.rb
|
523
530
|
- lib/opal/nodes/call_special.rb
|
524
|
-
- lib/opal/nodes/case.rb
|
525
531
|
- lib/opal/nodes/class.rb
|
526
532
|
- lib/opal/nodes/constants.rb
|
527
533
|
- lib/opal/nodes/csend.rb
|
@@ -557,6 +563,7 @@ files:
|
|
557
563
|
- lib/opal/paths.rb
|
558
564
|
- lib/opal/regexp_anchors.rb
|
559
565
|
- lib/opal/repl.rb
|
566
|
+
- lib/opal/requires.rb
|
560
567
|
- lib/opal/rewriter.rb
|
561
568
|
- lib/opal/rewriters/arguments.rb
|
562
569
|
- lib/opal/rewriters/base.rb
|
@@ -603,7 +610,13 @@ files:
|
|
603
610
|
- opal/corelib/dir.rb
|
604
611
|
- opal/corelib/enumerable.rb
|
605
612
|
- opal/corelib/enumerator.rb
|
613
|
+
- opal/corelib/enumerator/arithmetic_sequence.rb
|
614
|
+
- opal/corelib/enumerator/chain.rb
|
615
|
+
- opal/corelib/enumerator/generator.rb
|
616
|
+
- opal/corelib/enumerator/lazy.rb
|
617
|
+
- opal/corelib/enumerator/yielder.rb
|
606
618
|
- opal/corelib/error.rb
|
619
|
+
- opal/corelib/error/errno.rb
|
607
620
|
- opal/corelib/file.rb
|
608
621
|
- opal/corelib/hash.rb
|
609
622
|
- opal/corelib/helpers.rb
|
@@ -627,6 +640,7 @@ files:
|
|
627
640
|
- opal/corelib/proc.rb
|
628
641
|
- opal/corelib/process.rb
|
629
642
|
- opal/corelib/process/base.rb
|
643
|
+
- opal/corelib/process/status.rb
|
630
644
|
- opal/corelib/random.rb
|
631
645
|
- opal/corelib/random/formatter.rb
|
632
646
|
- opal/corelib/random/math_random.js.rb
|
@@ -656,6 +670,7 @@ files:
|
|
656
670
|
- spec/filters/bugs/basicobject.rb
|
657
671
|
- spec/filters/bugs/bigdecimal.rb
|
658
672
|
- spec/filters/bugs/binding.rb
|
673
|
+
- spec/filters/bugs/boolean.rb
|
659
674
|
- spec/filters/bugs/class.rb
|
660
675
|
- spec/filters/bugs/complex.rb
|
661
676
|
- spec/filters/bugs/date.rb
|
@@ -831,6 +846,7 @@ files:
|
|
831
846
|
- spec/opal/core/kernel/instance_variables_spec.rb
|
832
847
|
- spec/opal/core/kernel/methods_spec.rb
|
833
848
|
- spec/opal/core/kernel/public_methods_spec.rb
|
849
|
+
- spec/opal/core/kernel/puts_spec.rb
|
834
850
|
- spec/opal/core/kernel/require_tree_spec.rb
|
835
851
|
- spec/opal/core/kernel/respond_to_spec.rb
|
836
852
|
- spec/opal/core/language/DATA/characters_support_spec.rb
|
@@ -844,6 +860,7 @@ files:
|
|
844
860
|
- spec/opal/core/language/numblocks_spec.rb
|
845
861
|
- spec/opal/core/language/pattern_matching_spec.rb
|
846
862
|
- spec/opal/core/language/safe_navigator_spec.rb
|
863
|
+
- spec/opal/core/language/super_spec.rb
|
847
864
|
- spec/opal/core/language/while_spec.rb
|
848
865
|
- spec/opal/core/language_spec.rb
|
849
866
|
- spec/opal/core/marshal/dump_spec.rb
|
@@ -961,6 +978,7 @@ files:
|
|
961
978
|
- stdlib/native.rb
|
962
979
|
- stdlib/nodejs.rb
|
963
980
|
- stdlib/nodejs/argf.rb
|
981
|
+
- stdlib/nodejs/base.rb
|
964
982
|
- stdlib/nodejs/dir.rb
|
965
983
|
- stdlib/nodejs/env.rb
|
966
984
|
- stdlib/nodejs/file.rb
|
@@ -1045,6 +1063,14 @@ files:
|
|
1045
1063
|
- stdlib/opal/repl_js.rb
|
1046
1064
|
- stdlib/opal/replutils.rb
|
1047
1065
|
- stdlib/open-uri.rb
|
1066
|
+
- stdlib/optparse.rb
|
1067
|
+
- stdlib/optparse/ac.rb
|
1068
|
+
- stdlib/optparse/date.rb
|
1069
|
+
- stdlib/optparse/kwargs.rb
|
1070
|
+
- stdlib/optparse/shellwords.rb
|
1071
|
+
- stdlib/optparse/time.rb
|
1072
|
+
- stdlib/optparse/uri.rb
|
1073
|
+
- stdlib/optparse/version.rb
|
1048
1074
|
- stdlib/ostruct.rb
|
1049
1075
|
- stdlib/pathname.rb
|
1050
1076
|
- stdlib/pp.rb
|
@@ -1060,6 +1086,7 @@ files:
|
|
1060
1086
|
- stdlib/rbconfig/sizeof.rb
|
1061
1087
|
- stdlib/securerandom.rb
|
1062
1088
|
- stdlib/set.rb
|
1089
|
+
- stdlib/shellwords.rb
|
1063
1090
|
- stdlib/singleton.rb
|
1064
1091
|
- stdlib/stringio.rb
|
1065
1092
|
- stdlib/strscan.rb
|
@@ -1124,10 +1151,10 @@ licenses:
|
|
1124
1151
|
metadata:
|
1125
1152
|
homepage_uri: https://opalrb.com/
|
1126
1153
|
bug_tracker_uri: https://github.com/opal/opal/issues
|
1127
|
-
changelog_uri: https://github.com/opal/opal/blob/v1.
|
1128
|
-
readme_uri: https://github.com/opal/opal/blob/v1.
|
1129
|
-
api_documentation_uri: http://opalrb.com/docs/api/v1.
|
1130
|
-
guides_uri: http://opalrb.com/docs/guides/v1.
|
1154
|
+
changelog_uri: https://github.com/opal/opal/blob/v1.4.0.alpha1/CHANGELOG.md
|
1155
|
+
readme_uri: https://github.com/opal/opal/blob/v1.4.0.alpha1/README.md
|
1156
|
+
api_documentation_uri: http://opalrb.com/docs/api/v1.4.0.alpha1/index.html
|
1157
|
+
guides_uri: http://opalrb.com/docs/guides/v1.4.0.alpha1/index.html
|
1131
1158
|
chat_uri: https://gitter.im/opal/opal
|
1132
1159
|
source_code_uri: https://github.com/opal/opal
|
1133
1160
|
post_install_message:
|
@@ -1141,9 +1168,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1141
1168
|
version: '2.3'
|
1142
1169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1143
1170
|
requirements:
|
1144
|
-
- - "
|
1171
|
+
- - ">"
|
1145
1172
|
- !ruby/object:Gem::Version
|
1146
|
-
version:
|
1173
|
+
version: 1.3.1
|
1147
1174
|
requirements: []
|
1148
1175
|
rubygems_version: 3.2.3
|
1149
1176
|
signing_key:
|
@@ -1186,6 +1213,7 @@ test_files:
|
|
1186
1213
|
- benchmark-ips/bm_is_number.rb
|
1187
1214
|
- benchmark-ips/bm_js_symbols_vs_strings.rb
|
1188
1215
|
- benchmark-ips/bm_symbol_to_proc.rb
|
1216
|
+
- benchmark-ips/bm_truthy.rb
|
1189
1217
|
- benchmark-ips/bm_while_true_vs_loop.rb
|
1190
1218
|
- benchmark-ips/class_shovel_vs_singleton_class.rb
|
1191
1219
|
- benchmark/benchmarks
|
@@ -1436,7 +1464,6 @@ test_files:
|
|
1436
1464
|
- lib/opal/nodes/base.rb
|
1437
1465
|
- lib/opal/nodes/call.rb
|
1438
1466
|
- lib/opal/nodes/call_special.rb
|
1439
|
-
- lib/opal/nodes/case.rb
|
1440
1467
|
- lib/opal/nodes/class.rb
|
1441
1468
|
- lib/opal/nodes/constants.rb
|
1442
1469
|
- lib/opal/nodes/csend.rb
|
@@ -1472,6 +1499,7 @@ test_files:
|
|
1472
1499
|
- lib/opal/paths.rb
|
1473
1500
|
- lib/opal/regexp_anchors.rb
|
1474
1501
|
- lib/opal/repl.rb
|
1502
|
+
- lib/opal/requires.rb
|
1475
1503
|
- lib/opal/rewriter.rb
|
1476
1504
|
- lib/opal/rewriters/arguments.rb
|
1477
1505
|
- lib/opal/rewriters/base.rb
|
@@ -1518,7 +1546,13 @@ test_files:
|
|
1518
1546
|
- opal/corelib/dir.rb
|
1519
1547
|
- opal/corelib/enumerable.rb
|
1520
1548
|
- opal/corelib/enumerator.rb
|
1549
|
+
- opal/corelib/enumerator/arithmetic_sequence.rb
|
1550
|
+
- opal/corelib/enumerator/chain.rb
|
1551
|
+
- opal/corelib/enumerator/generator.rb
|
1552
|
+
- opal/corelib/enumerator/lazy.rb
|
1553
|
+
- opal/corelib/enumerator/yielder.rb
|
1521
1554
|
- opal/corelib/error.rb
|
1555
|
+
- opal/corelib/error/errno.rb
|
1522
1556
|
- opal/corelib/file.rb
|
1523
1557
|
- opal/corelib/hash.rb
|
1524
1558
|
- opal/corelib/helpers.rb
|
@@ -1542,6 +1576,7 @@ test_files:
|
|
1542
1576
|
- opal/corelib/proc.rb
|
1543
1577
|
- opal/corelib/process.rb
|
1544
1578
|
- opal/corelib/process/base.rb
|
1579
|
+
- opal/corelib/process/status.rb
|
1545
1580
|
- opal/corelib/random.rb
|
1546
1581
|
- opal/corelib/random/formatter.rb
|
1547
1582
|
- opal/corelib/random/math_random.js.rb
|
@@ -1604,6 +1639,7 @@ test_files:
|
|
1604
1639
|
- stdlib/native.rb
|
1605
1640
|
- stdlib/nodejs.rb
|
1606
1641
|
- stdlib/nodejs/argf.rb
|
1642
|
+
- stdlib/nodejs/base.rb
|
1607
1643
|
- stdlib/nodejs/dir.rb
|
1608
1644
|
- stdlib/nodejs/env.rb
|
1609
1645
|
- stdlib/nodejs/file.rb
|
@@ -1688,6 +1724,14 @@ test_files:
|
|
1688
1724
|
- stdlib/opal/repl_js.rb
|
1689
1725
|
- stdlib/opal/replutils.rb
|
1690
1726
|
- stdlib/open-uri.rb
|
1727
|
+
- stdlib/optparse.rb
|
1728
|
+
- stdlib/optparse/ac.rb
|
1729
|
+
- stdlib/optparse/date.rb
|
1730
|
+
- stdlib/optparse/kwargs.rb
|
1731
|
+
- stdlib/optparse/shellwords.rb
|
1732
|
+
- stdlib/optparse/time.rb
|
1733
|
+
- stdlib/optparse/uri.rb
|
1734
|
+
- stdlib/optparse/version.rb
|
1691
1735
|
- stdlib/ostruct.rb
|
1692
1736
|
- stdlib/pathname.rb
|
1693
1737
|
- stdlib/pp.rb
|
@@ -1703,6 +1747,7 @@ test_files:
|
|
1703
1747
|
- stdlib/rbconfig/sizeof.rb
|
1704
1748
|
- stdlib/securerandom.rb
|
1705
1749
|
- stdlib/set.rb
|
1750
|
+
- stdlib/shellwords.rb
|
1706
1751
|
- stdlib/singleton.rb
|
1707
1752
|
- stdlib/stringio.rb
|
1708
1753
|
- stdlib/strscan.rb
|
data/lib/opal/nodes/case.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'opal/nodes/base'
|
4
|
-
|
5
|
-
module Opal
|
6
|
-
module Nodes
|
7
|
-
class CaseNode < Base
|
8
|
-
handle :case
|
9
|
-
|
10
|
-
children :condition
|
11
|
-
|
12
|
-
def compile
|
13
|
-
compiler.in_case do
|
14
|
-
compile_code
|
15
|
-
|
16
|
-
if needs_closure?
|
17
|
-
if scope.await_encountered
|
18
|
-
wrap '(await (async function() {', '})())'
|
19
|
-
else
|
20
|
-
wrap '(function() {', '})()'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def compile_code
|
27
|
-
handled_else = false
|
28
|
-
|
29
|
-
if condition
|
30
|
-
case_stmt[:cond] = true
|
31
|
-
add_local '$case'
|
32
|
-
|
33
|
-
push '$case = ', expr(condition), ';'
|
34
|
-
end
|
35
|
-
|
36
|
-
case_parts.each_with_index do |wen, idx|
|
37
|
-
next unless wen
|
38
|
-
line
|
39
|
-
case wen.type
|
40
|
-
when :when
|
41
|
-
wen = compiler.returns(wen) if needs_closure?
|
42
|
-
push 'else ' unless idx == 0
|
43
|
-
push stmt(wen)
|
44
|
-
else # s(:else)
|
45
|
-
handled_else = true
|
46
|
-
wen = compiler.returns(wen) if needs_closure?
|
47
|
-
push 'else {', stmt(wen), '}'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# if we are having a closure, we must return a usable value
|
52
|
-
if needs_closure? && !handled_else
|
53
|
-
line
|
54
|
-
push 'else { return nil }'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def needs_closure?
|
59
|
-
!stmt?
|
60
|
-
end
|
61
|
-
|
62
|
-
def case_parts
|
63
|
-
children[1..-1]
|
64
|
-
end
|
65
|
-
|
66
|
-
def case_stmt
|
67
|
-
compiler.case_stmt
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class WhenNode < Base
|
72
|
-
handle :when
|
73
|
-
|
74
|
-
children :whens, :body
|
75
|
-
|
76
|
-
def compile
|
77
|
-
push 'if ('
|
78
|
-
|
79
|
-
when_checks.each_with_index do |check, idx|
|
80
|
-
push ' || ' unless idx == 0
|
81
|
-
|
82
|
-
if check.type == :splat
|
83
|
-
push '(function($splt) { for (var i = 0, ii = $splt.length; i < ii; i++) {'
|
84
|
-
if case_stmt[:cond]
|
85
|
-
push "if ($splt[i]['$===']($case)) { return true; }"
|
86
|
-
else
|
87
|
-
push 'if (', js_truthy(check), ')) { return true; }'
|
88
|
-
end
|
89
|
-
push '} return false; })(', expr(check.children[0]), ')'
|
90
|
-
elsif case_stmt[:cond]
|
91
|
-
call = s(:send, check, :===, s(:arglist, s(:js_tmp, '$case')))
|
92
|
-
push expr(call)
|
93
|
-
else
|
94
|
-
push js_truthy(check)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
push ') {', process(body_code, @level), '}'
|
99
|
-
end
|
100
|
-
|
101
|
-
def when_checks
|
102
|
-
children[0..-2]
|
103
|
-
end
|
104
|
-
|
105
|
-
def case_stmt
|
106
|
-
compiler.case_stmt
|
107
|
-
end
|
108
|
-
|
109
|
-
def body_code
|
110
|
-
children.last || s(:nil)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|