opal 1.6.0.alpha1 → 1.6.0.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 799fb70bbdbc0be33af9c9757287797702fd8752f29e3beb4b3515f3dc0e7a66
4
- data.tar.gz: 757ec0cb6cc3a5bb24e7a6e6e2aec81fa70d5f05f98025ee00528d00b0779d48
3
+ metadata.gz: 9bc96268e7c234e02e983299ec4e04de40283cd5dec33a944aca6567bddaf927
4
+ data.tar.gz: 34a0a446e2c6a8564cb1ec9523a88acfaf667f2b35d77aebde437e5658eb8b95
5
5
  SHA512:
6
- metadata.gz: f3024674d274a45c92bbb5094416074ef754802a78c0484a71d68a7b03815867a8ac42f8499e23a9f2d05587212afeafb752c0894cfabc4a6ace63faf0da4098
7
- data.tar.gz: f1d8ec6f6ac95d89233d4af4a26ab4eaed8d275edd86b154dd06d6fea5477c9aa869dc644f571a2c95737bf674703f03db9b8bed7b43a8af322d5dad6e3a0516
6
+ metadata.gz: 470926fc4eb90e7effc90cc193fdf80746f26ecffff79ddd602c7c275e2e17638206a230079370f3fd30923f00988bd497f1ec38914ae50fa49a90ff76ab14a6
7
+ data.tar.gz: 83fa53a8d529538c321dad65ba704e4ec3fd4ab92e8de57a2865fb1da38a205008729eddd5444e1f7c15ef19cc11f228e0cad9d692e32c558cf346fac62c1c66
data/.gitattributes CHANGED
@@ -1 +1,5 @@
1
1
  UNRELEASED.md merge=union
2
+ spec/opal/core/language/DATA/characters_support_crlf_spec.rb text eol=crlf
3
+ spec/opal/core/language/DATA/characters_support_spec.rb text eol=lf
4
+ spec/opal/core/language/DATA/multiple___END___crlf_spec.rb text eol=crlf
5
+ spec/opal/core/language/DATA/multiple___END___spec.rb text eol=lf
@@ -45,9 +45,20 @@ jobs:
45
45
  - name: smoke-test
46
46
  ruby: '3.0'
47
47
  command: bin/rake smoke_test
48
+ - name: windows-mspec-nodejs
49
+ command: bundle exec rake mspec_nodejs
50
+ ruby: '3.0'
51
+ os: windows-latest
52
+ - name: windows-mspec-chrome
53
+ command: bundle exec rake mspec_chrome
54
+ ruby: '3.0'
55
+ os: windows-latest
56
+ - name: windows-minitest
57
+ command: bundle exec rake minitest
58
+ ruby: '3.0'
59
+ os: windows-latest
48
60
  - name: windows
49
- # These two fail because of broken stacktraces on windows: minitest_node_nodejs mspec_nodejs
50
- command: bundle exec rake rspec minitest_nodejs
61
+ command: bundle exec rake rspec
51
62
  ruby: '3.0'
52
63
  os: windows-latest
53
64
  - name: lint
data/README.md CHANGED
@@ -18,14 +18,14 @@
18
18
  <a href="#sponsors"><img src="https://opencollective.com/opal/sponsors/badge.svg" alt="Sponsors on Open Collective" title="" /></a>
19
19
  <a href="https://slack.opalrb.com/"><img src="https://img.shields.io/badge/slack-join%20chat-46BC99?logo=slack&style=flat" alt="Slack" title="Join Chat" /></a>
20
20
  <a href="https://opalrb.com/docs"><img src="https://img.shields.io/badge/docs-updated-blue.svg" alt="Documentation" title="" /></a>
21
-
21
+
22
22
  <br>
23
23
  <strong>Code:</strong><br>
24
24
  <a href="https://badge.fury.io/rb/opal"><img src="https://img.shields.io/gem/v/opal.svg?style=flat" alt="Gem Version" title="" /></a>
25
25
  <a href="https://github.com/opal/opal/actions?query=workflow%3Abuild"><img src="https://github.com/opal/opal/workflows/build/badge.svg" alt="Build Status" /></a>
26
26
  <a href="https://codeclimate.com/github/opal/opal"><img src="https://img.shields.io/codeclimate/maintainability-percentage/opal/opal.svg" alt="Code Climate" title="" /></a>
27
27
  <a href="https://coveralls.io/github/opal/opal?branch=master"><img src="https://coveralls.io/repos/opal/opal/badge.svg?branch=master&amp;service=github" alt="Coverage Status" title="" /></a>
28
-
28
+
29
29
  <br>
30
30
  <strong>Sponsors:</strong>
31
31
  <br/><a href="https://nebulab.it?utm_source=github&utm_medium=badge"><img src="https://img.shields.io/static/v1?label=Nebulab&message=Open+Source+Fridays&color=%235dbefd&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMQSURBVHgBrZZNTxNRFIbfczsgIMQiLBCRFDaGhUr9A9iiIa5EEneIwE/AlRsNv8KlIKwFl35RTUBX8rFBdiVKAgqmXSCY0M71nJl+zJTOdKh9k6Yzc8/cZ86555x7CQE0mji5hSyGlQoNaOgIPwrnhtIArWszu4EQFudjdR8rzUV+gw8/ZMZB9IwvIwimJJGafhmjWZwFOJ7QkYzWCwTdj+qUDJGKz8Rou3RAlT4YS+hHWW2u/QdM1MNzrI6+zwyXDrg8FANStIDaSXOIJ5whLgAljOIZiglRK6U4vDfz4S2ElGGJWsEaQkCTUbhtNbV+lb+xgFY2Bs9ET0h/GzBxlfAkqnCUKY5xKfVLbsi1/R126lcF6WgCYp2ES42EBp6tvQFY+alLTUlrUxizJEVNWiVwBkVagGg7oe+CDclLYOfrgMdfTBz8PfWa1lkzbsDEsH/5FyF9YUK0zQ1xwpoZtsm9pwxMRLyA9wyi0A2Jcjl1NNqeeEFEimxYPkmWd014ikIDnDTeBb53DOweaRxnvWGyhnmYfPZWGt487sNi6lsK67/lZ1oZGOtUaD3nhtU7etXXfe0VzrzCBgLKCR68rNDX6oaJlvd0xXnklbSfgSTL/QghXF8EP980cVKyVL/Ys9UDVFJa8Tdt+1lYmcmJM3Vd4UEvWeslRf32h9ubrVRl77gBrCto85OfUU+LXTMGx+JuN2Hoin3/Zkfjj6ObBAknV+KG4jpc9BqXMEpiCMz6Z9ZQ12kvJZxb6co4Zr1W83esY8F2OYsIe+eEyfTiVXczCl7uM2wliHfMEJaRc3Wa++mLUotrF4EW7h6f94Dvh6aVFM60Fy8Xkya+BfBOjh5yUWhqY0vmKi9q1GnVxZ7sHKIWSs7FQ71yUagkRTTCfymnVY1gsgHHC5z8hbUjaz0Fr8ZanXhX0pPOw5SrV8wNGjNscMrTKpXKaj05f9twVYHnMZGPHEuwTwEBNi+3NGiNt6GRcsfEIAfhp2cAV3cQLtXoOz7q8+ZJRLx3kmxn4dy7aas1SrfiBpKraV/9A+PSJLDAXLUvAAAAAElFTkSuQmCC" alt="Nebulab: Open Source Fridays" /></a>
@@ -99,7 +99,7 @@ or to build an entire app including dependencies declared with `require`:
99
99
  ```ruby
100
100
  builder = Opal::Builder.new
101
101
  builder.build_str('require "opal"; puts "wow"', '(inline)')
102
- File.write 'app.js', builder.to_s
102
+ File.binwrite 'app.js', builder.to_s # must use binary mode for writing
103
103
  ```
104
104
 
105
105
 
data/UNRELEASED.md CHANGED
@@ -29,7 +29,8 @@
29
29
  - Delegate and ruby2_keywords (#2446)
30
30
  - Source code can now be embedded in the compiled file to improve development/debugging, e.g. RSpec reports, `Proc#source_location` (#2440)
31
31
  - Added `Kernel#caller_locations` (#2440)
32
- - `Opal::Builder::Prefork` for blazingly fast multicore compilation times (#2263, #2462, #2454)
32
+ - `Opal::Builder::Prefork` for blazingly fast multicore compilation times (#2263, #2462, #2454, #2469, #2475)
33
+ - Add `Opal::BuilderProcessors::RubyERBProcessor` (#2470)
33
34
 
34
35
  ### Fixed
35
36
 
@@ -42,6 +43,9 @@
42
43
  - Compilation error occurs while compiling `being/end` returning a `case/when` (#2459)
43
44
  - Ensure UTF-8 encoding of `.sourcesContent` of source maps (#2451)
44
45
  - Benchmarks require string/unpack (#2453)
46
+ - Fix compilation of a call: `gets&.chomp` (#2473)
47
+ - Fix specs on Windows (#2460)
48
+ - Make opal CLI tool work again with pipes (#2474)
45
49
 
46
50
  ### Internal
47
51
 
@@ -49,3 +53,4 @@
49
53
  - Retry if file cache write operation exits with Zlib::BufError (#2463)
50
54
  - Eliminate redundant `var constructor` in `allocate_class` (#2452)
51
55
  - Fix `performance:compare` asset size calculation (#2457)
56
+ - Fix a few specs after the Opal RSpec 1.0 (alpha) release (#2471, #2472)
data/docs/jquery.md CHANGED
@@ -58,7 +58,7 @@ builder.build('opal')
58
58
  builder.build('opal-jquery')
59
59
  builder.build('./app/application.rb')
60
60
 
61
- File.write('application.js', builder.to_s)
61
+ File.binwrite('application.js', builder.to_s) # must use binary mode for writing
62
62
  ```
63
63
 
64
64
  then simply load the compiled file in your html:
@@ -67,7 +67,7 @@ then simply load the compiled file in your html:
67
67
  <!DOCTYPE html>
68
68
  <html>
69
69
  <head>
70
- <script src='https://code.jquery.com/jquery-3.3.1.min.js' integrity='sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=' crossorigin='anonymous'></script>
70
+ <script src='https://code.jquery.com/jquery-3.3.1.min.js' integrity='sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=' crossorigin='anonymous'></script>
71
71
  <script type='text/javascript' src='./application.js'></script>
72
72
  </head>
73
73
  <body></body>
@@ -75,11 +75,11 @@ then simply load the compiled file in your html:
75
75
  ```
76
76
 
77
77
  NOTE: opal-jquery expects a jquery library to be loaded. This example loads it
78
- remotely from jquery.com, but a locally downloaded copy works just as well, or-
78
+ remotely from jquery.com, but a locally downloaded copy works just as well, or-
79
79
  if you're using rails- jquery may be included automatically.
80
80
 
81
- This example builds opal, opal-jquery and the application into a single `.js` file,
82
- but you may build them separately, if you so choose. Just remember to include
81
+ This example builds opal, opal-jquery and the application into a single `.js` file,
82
+ but you may build them separately, if you so choose. Just remember to include
83
83
  each respective script in your html!
84
84
 
85
85
  ### How does opal-jquery work
@@ -114,6 +114,12 @@ module Opal
114
114
  end
115
115
  end
116
116
 
117
+ # This handler is for files named ".opalerb", which ought to
118
+ # first get compiled to Ruby code using ERB, then with Opal.
119
+ # Unlike below processors, OpalERBProcessor can be used to
120
+ # compile templates, which will in turn output HTML. Take
121
+ # a look at docs/templates.md to understand this subsystem
122
+ # better.
117
123
  class OpalERBProcessor < RubyProcessor
118
124
  handles :opalerb
119
125
 
@@ -133,6 +139,24 @@ module Opal
133
139
  end
134
140
  end
135
141
 
142
+ # This handler is for files named ".rb.erb", which ought to
143
+ # first get preprocessed via ERB, then via Opal.
144
+ class RubyERBProcessor < RubyProcessor
145
+ handles :"rb.erb"
146
+
147
+ def compiled
148
+ @compiled ||= begin
149
+ @source = ::ERB.new(@source.to_s).result
150
+
151
+ compiler = compiler_for(@source, file: @filename)
152
+ compiler.compile
153
+ compiler
154
+ end
155
+ end
156
+ end
157
+
158
+ # This handler is for files named ".js.erb", which ought to
159
+ # first get preprocessed via ERB, then served verbatim as JS.
136
160
  class ERBProcessor < Processor
137
161
  handles :erb
138
162
 
@@ -161,6 +161,9 @@ module Opal
161
161
  end
162
162
 
163
163
  def fork_entrypoint(io)
164
+ # Ensure we can work with our forks async...
165
+ Fiber.set_scheduler(nil) if Fiber.respond_to? :set_scheduler
166
+
164
167
  @in_fork = io
165
168
 
166
169
  until io.eof?
@@ -19,15 +19,21 @@ module Opal
19
19
 
20
20
  def set(key, data)
21
21
  file = cache_filename_for(key)
22
-
23
22
  out = Marshal.dump(data)
24
- out = Zlib.gzip(out, level: 9)
23
+
24
+ # Sometimes `Zlib::BufError` gets raised, unsure why, makes no sense, possibly
25
+ # some race condition (see https://github.com/ruby/zlib/issues/49).
26
+ # Limit the number of retries to avoid infinite loops.
27
+ retries = 5
28
+ begin
29
+ out = Zlib.gzip(out, level: 9)
30
+ rescue Zlib::BufError
31
+ warn "\n[Opal]: Zlib::BufError; retrying (#{retries} retries left)"
32
+ retries -= 1
33
+ retry if retries > 0
34
+ end
35
+
25
36
  File.binwrite(file, out)
26
- rescue Zlib::BufError
27
- # This sometimes happens, unsure why, makes no sense, possibly
28
- # some race condition
29
- warn '[Opal]: Zlib::BufError; retrying'
30
- retry
31
37
  end
32
38
 
33
39
  def get(key)
data/lib/opal/cli.rb CHANGED
@@ -184,8 +184,21 @@ module Opal
184
184
  if evals.any?
185
185
  yield evals.join("\n"), '-e'
186
186
  elsif file && (filename != '-' || evals.empty?)
187
- file.rewind
188
- yield file.read, filename
187
+ return @content if @content
188
+
189
+ if file.tty?
190
+ save = true
191
+ else
192
+ begin
193
+ file.rewind
194
+ rescue Errno::ESPIPE
195
+ save = true
196
+ end
197
+ end
198
+
199
+ content = yield(file.read, filename)
200
+ @content = content if save
201
+ content
189
202
  end
190
203
  end
191
204
  end
@@ -66,7 +66,7 @@ module Opal
66
66
  def prepare_files_in(dir)
67
67
  js = builder.to_s
68
68
  map = builder.source_map.to_json
69
- stack = File.read("#{__dir__}/source-map-support-browser.js")
69
+ stack = File.binread("#{__dir__}/source-map-support-browser.js")
70
70
 
71
71
  ext = builder.output_extension
72
72
  module_type = ' type="module"' if builder.esm?
@@ -74,9 +74,9 @@ module Opal
74
74
  # Chrome can't handle huge data passed to `addScriptToEvaluateOnLoad`
75
75
  # https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/U5qyeX_ydBo
76
76
  # The only way is to create temporary files and pass them to chrome.
77
- File.write("#{dir}/index.#{ext}", js)
78
- File.write("#{dir}/source-map-support.js", stack)
79
- File.write("#{dir}/index.html", <<~HTML)
77
+ File.binwrite("#{dir}/index.#{ext}", js)
78
+ File.binwrite("#{dir}/source-map-support.js", stack)
79
+ File.binwrite("#{dir}/index.html", <<~HTML)
80
80
  <html><head>
81
81
  <meta charset='utf-8'>
82
82
  <script src='./source-map-support.js'></script>
@@ -124,7 +124,7 @@ module Opal
124
124
 
125
125
  chrome_pid = Process.spawn(chrome_server_cmd)
126
126
 
127
- Timeout.timeout(10) do
127
+ Timeout.timeout(30) do
128
128
  loop do
129
129
  break if chrome_server_running?
130
130
  sleep 0.5
@@ -137,7 +137,7 @@ module Opal
137
137
  puts 'Make sure that you have it installed and that its version is > 59'
138
138
  exit(1)
139
139
  ensure
140
- if windows? && chrome_pid
140
+ if OS.windows? && chrome_pid
141
141
  Process.kill('KILL', chrome_pid) unless system("taskkill /f /t /pid #{chrome_pid} >NUL 2>NUL")
142
142
  elsif chrome_pid
143
143
  Process.kill('HUP', chrome_pid)
@@ -27,9 +27,9 @@ SystemRunner = ->(data, &block) {
27
27
 
28
28
  tempfile =
29
29
  if debug
30
- File.new("opal-nodejs-runner.#{ext}", 'w')
30
+ File.new("opal-nodejs-runner.#{ext}", 'wb')
31
31
  else
32
- Tempfile.new(['opal-system-runner', ".#{ext}"])
32
+ Tempfile.new(['opal-system-runner', ".#{ext}"], mode: File::BINARY)
33
33
  end
34
34
 
35
35
  tempfile.write code
@@ -15,9 +15,12 @@ module Opal
15
15
  eof_content = @source[last_token_position..-1]
16
16
  return nil unless eof_content
17
17
 
18
- eof_content = eof_content.lines.drop_while { |line| line == "\n" }
18
+ # On Windows token position is off a bit, because Parser does not seem to compensate for \r\n
19
+ # The first eof_content line on Windows may be for example "end\r\n"
20
+ # Must match for it and \r\n and \n
21
+ eof_content = eof_content.lines.drop_while { |line| /\A.*\r?\n?\z/.match?(line) && !line.start_with?('__END__') }
19
22
 
20
- if eof_content[0] == "__END__\n"
23
+ if /\A__END__\r?\n?\z/.match?(eof_content[0])
21
24
  eof_content = eof_content[1..-1] || []
22
25
  eof_content.join
23
26
  elsif eof_content == ['__END__']
@@ -186,7 +186,8 @@ module Opal
186
186
  end
187
187
 
188
188
  def compile_simple_call_chain
189
- push recv(receiver_sexp), method_jsid, '(', expr(arglist), ')'
189
+ compile_receiver
190
+ push method_jsid, '(', expr(arglist), ')'
190
191
  end
191
192
 
192
193
  def splat?
@@ -469,7 +470,7 @@ module Opal
469
470
  def handle_conditional_send
470
471
  # temporary variable that stores method receiver
471
472
  receiver_temp = scope.new_temp
472
- push "#{receiver_temp} = ", expr(recvr)
473
+ push "#{receiver_temp} = ", expr(receiver_sexp)
473
474
 
474
475
  # execute the sexp only if the receiver isn't nil
475
476
  push ", (#{receiver_temp} === nil || #{receiver_temp} == null) ? nil : "
@@ -182,8 +182,9 @@ class Opal::SourceMap::File
182
182
  def fragments_by_line
183
183
  raw_mappings = [[]]
184
184
  fragments.flat_map do |fragment|
185
- fragment_code = fragment.code
186
- fragment_lines = fragment_code.split("\n", -1) # a negative limit won't suppress trailing null values
185
+ fragment_code = fragment.code
186
+ splitter = /\r/.match?(fragment_code) ? /\r?\n/ : "\n"
187
+ fragment_lines = fragment_code.split(splitter, -1) # a negative limit won't suppress trailing null values
187
188
  fragment_lines.each.with_index do |fragment_line, index|
188
189
  raw_segment = [fragment_line, fragment]
189
190
  if index.zero? && !fragment_line.size.zero?
data/lib/opal/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  module Opal
4
4
  # WHEN RELEASING:
5
5
  # Remember to update RUBY_ENGINE_VERSION in opal/corelib/constants.rb too!
6
- VERSION = '1.6.0.alpha1'
6
+ VERSION = '1.6.0.rc1'
7
7
  end
@@ -1,8 +1,8 @@
1
1
  ::RUBY_PLATFORM = 'opal'
2
2
  ::RUBY_ENGINE = 'opal'
3
3
  ::RUBY_VERSION = '3.1.0'
4
- ::RUBY_ENGINE_VERSION = '1.6.0.alpha1'
5
- ::RUBY_RELEASE_DATE = '2022-11-11'
4
+ ::RUBY_ENGINE_VERSION = '1.6.0.rc1'
5
+ ::RUBY_RELEASE_DATE = '2022-11-18'
6
6
  ::RUBY_PATCHLEVEL = 0
7
7
  ::RUBY_REVISION = '0'
8
8
  ::RUBY_COPYRIGHT = 'opal - Copyright (C) 2013-2022 Adam Beynon and the Opal contributors'
@@ -4,6 +4,7 @@ module ::Errno
4
4
  [:EEXIST, 'File exists', 17],
5
5
  [:EISDIR, 'Is a directory', 21],
6
6
  [:EMFILE, 'Too many open files', 24],
7
+ [:ESPIPE, 'Illegal seek', 29],
7
8
  [:EACCES, 'Permission denied', 13],
8
9
  [:EPERM, 'Operation not permitted', 1],
9
10
  [:ENOENT, 'No such file or directory', 2],
data/opal/corelib/io.rb CHANGED
@@ -89,7 +89,7 @@ class ::IO
89
89
  parts = ''
90
90
 
91
91
  # Will execure at most twice - one time reading from a buffer
92
- # second time
92
+ # second time executing read proc
93
93
  begin
94
94
  @read_buffer += parts
95
95
  if @read_buffer != ''
data/opal.gemspec CHANGED
@@ -44,9 +44,9 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency 'rack-test'
45
45
  spec.add_development_dependency 'selenium-webdriver'
46
46
  spec.add_development_dependency 'benchmark-ips', '< 2.8'
47
- spec.add_development_dependency 'sinatra'
47
+ spec.add_development_dependency 'sinatra', '~> 3.0'
48
48
  spec.add_development_dependency 'rubocop', '~> 0.67.0'
49
49
  spec.add_development_dependency 'rubocop-performance', '~> 1.1.0'
50
- spec.add_development_dependency 'rack'
50
+ spec.add_development_dependency 'rack', '~> 2.2'
51
51
  spec.add_development_dependency 'webrick'
52
52
  end
data/spec/lib/cli_spec.rb CHANGED
@@ -236,6 +236,20 @@ RSpec.describe Opal::CLI do
236
236
  end
237
237
  end
238
238
 
239
+ context 'using pipes' do
240
+ it 'runs the provided source' do
241
+ # `echo` on windows will output double-quotes along with the contents, that's why we print with ruby
242
+ expect(`ruby -e"puts 'foo'" | ruby bin/opal -ropal/platform -e "puts gets.reverse"`.strip).to eq("oof")
243
+ end
244
+
245
+ it 'compiles the provided source' do
246
+ # `echo` on windows will output double-quotes along with the contents, that's why we print with ruby
247
+ expect(`ruby -e"puts 'puts 123'" | ruby bin/opal -cEO`.strip).to include("self.$puts(123)")
248
+ end
249
+
250
+ # TODO: test refreshes with the server runner (only way to ensure we correctly rewind or cache the eval contents)
251
+ end
252
+
239
253
  private
240
254
 
241
255
  def expect_output_of
@@ -0,0 +1,9 @@
1
+ describe "characters support of the DATA contstant" do
2
+ it "supports all characters" do
3
+ DATA.read.should == "azAZ09`~!@#$%^&*(\r\n)_+{}\\|;:'\",<.>/?\r\n"
4
+ end
5
+ end
6
+
7
+ __END__
8
+ azAZ09`~!@#$%^&*(
9
+ )_+{}\|;:'",<.>/?
@@ -0,0 +1,10 @@
1
+ describe "DATA constant with multiple __END__ sections" do
2
+ it "returns everything after first __END__" do
3
+ DATA.read.should == "1\r\n__END__\r\n2\r\n"
4
+ end
5
+ end
6
+
7
+ __END__
8
+ 1
9
+ __END__
10
+ 2
@@ -4,4 +4,14 @@ describe 'Safe navigator' do
4
4
  value&.unknown.should == nil
5
5
  end
6
6
  end
7
+
8
+ it "calls a receiver exactly once" do
9
+ def receiver
10
+ @calls += 1
11
+ end
12
+ @calls = 0
13
+ receiver&.itself.should == 1
14
+ @calls = 0
15
+ receiver&.itself{}.should == 1
16
+ end
7
17
  end
data/tasks/testing.rake CHANGED
@@ -427,14 +427,15 @@ task :smoke_test do
427
427
  extend RSpec::Matchers
428
428
  expect(actual_output.lines[0]).to eq("..\n")
429
429
  expect(actual_output.lines[1]).to eq("\n")
430
- expect(actual_output.lines[2]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
431
- expect(actual_output.lines[3]).to eq("2 examples, 0 failures\n")
432
- expect(actual_output.lines[4]).to eq("\n")
433
- expect(actual_output.lines[5]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
434
- expect(actual_output.lines[7]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m \n})
430
+ expect(actual_output.lines[2]).to match(%r{Top 2 slowest examples \(\d+\.\d+ seconds, \d+\.\d+% of total time\):\n})
431
+ expect(actual_output.lines[4]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:7\n})
432
+ expect(actual_output.lines[6]).to match(%r{ \[1m\d+\.\d+\[0m \[1mseconds\[0m .*deprecations_spec\.rb:12\n})
433
+ expect(actual_output.lines[7]).to eq("\n")
434
+ expect(actual_output.lines[8]).to match(%r{^Finished in \d+\.\d+ seconds \(files took \d+\.\d+ seconds to load\)\n$})
435
+ expect(actual_output.lines[9]).to eq("2 examples, 0 failures\n")
435
436
  expect([
436
- actual_output.lines[6],
437
- actual_output.lines[8],
437
+ actual_output.lines[3],
438
+ actual_output.lines[5],
438
439
  ]).to contain_exactly(
439
440
  " Opal::Deprecations defaults to warn\n",
440
441
  " Opal::Deprecations can be set to raise\n",
@@ -175,6 +175,7 @@ class TestNodejsFile < Test::Unit::TestCase
175
175
  end if windows_platform?
176
176
 
177
177
  def test_windows_file_expand_path
178
+ # do not use d: because its a symlink in github actions fs, leading to unexpected results
178
179
  drive_letter = Dir.pwd.slice(0, 2)
179
180
  assert_equal(Dir.pwd + '/foo/bar.js', File.expand_path('./foo/bar.js'))
180
181
  assert_equal(drive_letter + '/foo/bar.js', File.expand_path('/foo/bar.js'))
@@ -186,8 +187,8 @@ class TestNodejsFile < Test::Unit::TestCase
186
187
  assert_equal('c:/bar.js', File.expand_path('\\..\\bar.js', 'c:\\foo\\baz\\'))
187
188
  assert_equal('c:/foo/baz/bar.js', File.expand_path('baz\\bar.js', 'c:\\foo'))
188
189
  assert_equal('c:/baz/bar.js', File.expand_path('baz\\bar.js', 'c:\\foo\\..'))
189
- assert_equal('d:/', File.expand_path('d:'), 'should add a trailing slash when the path is d:')
190
- assert_equal('d:/', File.expand_path('d:/'), 'should preserve the trailing slash when the path d:/')
190
+ assert_equal('f:/', File.expand_path('f:'), 'should add a trailing slash when the path is d:')
191
+ assert_equal('g:/', File.expand_path('g:/'), 'should preserve the trailing slash when the path d:/')
191
192
  assert_equal(Dir.pwd, File.expand_path(drive_letter), 'should expand to the current directory when the path is c: (and the current directory is located in the c drive)')
192
193
  assert_equal(drive_letter + '/', drive_letter + '/', 'should return c:/ when the path is c:/ because the path is absolute')
193
194
  end if windows_platform?
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.6.0.alpha1
4
+ version: 1.6.0.rc1
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: 2022-11-11 00:00:00.000000000 Z
13
+ date: 2022-11-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ast
@@ -162,16 +162,16 @@ dependencies:
162
162
  name: sinatra
163
163
  requirement: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '0'
167
+ version: '3.0'
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - ">="
172
+ - - "~>"
173
173
  - !ruby/object:Gem::Version
174
- version: '0'
174
+ version: '3.0'
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: rubocop
177
177
  requirement: !ruby/object:Gem::Requirement
@@ -204,16 +204,16 @@ dependencies:
204
204
  name: rack
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - ">="
207
+ - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: '0'
209
+ version: '2.2'
210
210
  type: :development
211
211
  prerelease: false
212
212
  version_requirements: !ruby/object:Gem::Requirement
213
213
  requirements:
214
- - - ">="
214
+ - - "~>"
215
215
  - !ruby/object:Gem::Version
216
- version: '0'
216
+ version: '2.2'
217
217
  - !ruby/object:Gem::Dependency
218
218
  name: webrick
219
219
  requirement: !ruby/object:Gem::Requirement
@@ -856,8 +856,10 @@ files:
856
856
  - spec/opal/core/kernel/puts_spec.rb
857
857
  - spec/opal/core/kernel/require_tree_spec.rb
858
858
  - spec/opal/core/kernel/respond_to_spec.rb
859
+ - spec/opal/core/language/DATA/characters_support_crlf_spec.rb
859
860
  - spec/opal/core/language/DATA/characters_support_spec.rb
860
861
  - spec/opal/core/language/DATA/empty___END___spec.rb
862
+ - spec/opal/core/language/DATA/multiple___END___crlf_spec.rb
861
863
  - spec/opal/core/language/DATA/multiple___END___spec.rb
862
864
  - spec/opal/core/language/arguments/mlhs_arg_spec.rb
863
865
  - spec/opal/core/language/forward_args_spec.rb
@@ -1167,10 +1169,10 @@ licenses:
1167
1169
  metadata:
1168
1170
  homepage_uri: https://opalrb.com/
1169
1171
  bug_tracker_uri: https://github.com/opal/opal/issues
1170
- changelog_uri: https://github.com/opal/opal/blob/v1.6.0.alpha1/CHANGELOG.md
1171
- readme_uri: https://github.com/opal/opal/blob/v1.6.0.alpha1/README.md
1172
- api_documentation_uri: http://opalrb.com/docs/api/v1.6.0.alpha1/index.html
1173
- guides_uri: http://opalrb.com/docs/guides/v1.6.0.alpha1/index.html
1172
+ changelog_uri: https://github.com/opal/opal/blob/v1.6.0.rc1/CHANGELOG.md
1173
+ readme_uri: https://github.com/opal/opal/blob/v1.6.0.rc1/README.md
1174
+ api_documentation_uri: http://opalrb.com/docs/api/v1.6.0.rc1/index.html
1175
+ guides_uri: http://opalrb.com/docs/guides/v1.6.0.rc1/index.html
1174
1176
  chat_uri: https://gitter.im/opal/opal
1175
1177
  source_code_uri: https://github.com/opal/opal
1176
1178
  post_install_message: