opal 0.10.0.beta1 → 0.10.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85f0110e658c1cefc27cccb2781d3a23e92531f0
4
- data.tar.gz: 46e3e241849788fa527985c5e5ad52837d315c02
3
+ metadata.gz: b0d30f54134e49ebcd91c2ece0dd0cf54a6d72ae
4
+ data.tar.gz: 57d3c8e202237d2e452523b1d772d8ddfe3baa24
5
5
  SHA512:
6
- metadata.gz: bd22ed6d034471bce5dfaee1b3b76f91aaf16ead1a0465c247d006f00901d90c96854bc8a4774d3b3ec34980c0b009675b6a6c8b63c64877801340cfd1f82eef
7
- data.tar.gz: ccb284eac1e8fe124ef80a3a0b7ad2fada35204eb141f252893d7babfc84b2a8a7143e12430219290bd771225a94723a080179fd0313003647b57bef3284cb94
6
+ metadata.gz: 0417410d72d8b82f366042085243ccd06d6d4394e46dbe507a3834e9df68d2ec5c76585b660466888ea6d3e8618e96f551e1e3482c3e66b0f270f5a9c4051482
7
+ data.tar.gz: da1d154ccf0f0ae319bed44b962e2ef6a588af39d22ede501cd7af7c7d8f095c9223bee1ecf0bafdf6b8500f605589d7c2b814daaf841b9caf5707ea6d0602a4
data/CHANGELOG.md CHANGED
@@ -105,6 +105,7 @@ Whitespace conventions:
105
105
  - Fixed parsing of `%{}` lists when list item contains same brackets.
106
106
  - Fixed an issue with `"-"` inside the second arg of `String#tr`
107
107
  - Fixed Base64 and enabled specs
108
+ - Fixed method definition in method body.
108
109
 
109
110
 
110
111
  ### Removed
@@ -14,11 +14,15 @@ module Opal
14
14
  arg_name = @sexp[1].to_sym
15
15
  var_name = variable(arg_name)
16
16
 
17
- default_value = scope.in_mlhs? ? "|| nil" : ""
18
-
19
17
  if @sexp.meta[:post]
20
18
  add_temp var_name
21
- line "#{var_name} = #{scope.working_arguments}.splice(0,1)[0] #{default_value};"
19
+ line "#{var_name} = #{scope.working_arguments}.splice(0,1)[0];"
20
+ end
21
+
22
+ if scope.in_mlhs?
23
+ line "if (#{var_name} == null) {"
24
+ line " #{var_name} = nil;"
25
+ line "}"
22
26
  end
23
27
  end
24
28
  end
@@ -120,6 +120,8 @@ module Opal
120
120
  elsif scope.top?
121
121
  unshift "Opal.defn(Opal.Object, '$#{mid}', "
122
122
  push ')'
123
+ elsif scope.def?
124
+ wrap "Opal.def(self, '$#{mid}', ", ')'
123
125
  else
124
126
  raise "Unsupported use of `def`; please file a bug at https://github.com/opal/opal reporting this message."
125
127
  end
data/lib/opal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  # WHEN RELEASING:
3
3
  # Remember to update RUBY_ENGINE_VERSION in opal/corelib/constants.rb too!
4
- VERSION = '0.10.0.beta1'
4
+ VERSION = '0.10.0.beta2'
5
5
  end
@@ -1,7 +1,7 @@
1
1
  RUBY_PLATFORM = 'opal'
2
2
  RUBY_ENGINE = 'opal'
3
3
  RUBY_VERSION = '2.2.3'
4
- RUBY_ENGINE_VERSION = '0.10.0.beta1'
4
+ RUBY_ENGINE_VERSION = '0.10.0.beta2'
5
5
  RUBY_RELEASE_DATE = '2015-12-20'
6
6
  RUBY_PATCHLEVEL = 0
7
7
  RUBY_REVISION = 0
@@ -202,3 +202,11 @@ module Kernel
202
202
  "See https://github.com/opal/opal/blob/#{RUBY_ENGINE_VERSION}/docs/opal_parser.md for details."
203
203
  end
204
204
  end
205
+
206
+ def self.public(*)
207
+ # stub
208
+ end
209
+
210
+ def self.private(*)
211
+ #stub
212
+ end
@@ -288,4 +288,22 @@ opal_filter "language" do
288
288
  fails "A Proc taking |(a, b)| arguments calls #to_ary to convert a single passed object to an Array"
289
289
  fails "A Proc taking |(a, b)| arguments calls #to_ary to convert a single passed object to an Array"
290
290
  fails "A Proc taking |(a, b)| arguments raises a TypeError if #to_ary does not return an Array"
291
+ fails "A singleton method definition can be declared for a local variable"
292
+ fails "A singleton method definition can be declared for an instance variable"
293
+ fails "A singleton method definition can be declared for a global variable"
294
+ fails "A singleton method definition can be declared for a class variable"
295
+ fails "A singleton method defined with extreme default arguments may use a method definition as a default"
296
+ fails "A singleton method defined with extreme default arguments may use an fcall as a default"
297
+ fails "A singleton method defined with extreme default arguments evaluates the defaults in the singleton scope"
298
+ fails "A singleton method defined with extreme default arguments may use preceding arguments as defaults"
299
+ fails "A singleton method defined with extreme default arguments may use a lambda as a default"
300
+ fails "A nested method definition creates an instance method when evaluated in an instance method"
301
+ fails "A nested method definition creates a class method when evaluated in a class method"
302
+ fails "A method defined with extreme default arguments may use an fcall as a default" # fails on phantomjs
303
+ fails "A method definition in an eval creates an instance method"
304
+ fails "A method definition in an eval creates a class method"
305
+ fails "A method definition in an eval creates a singleton method"
306
+ fails "An instance method with a default argument shadows an existing method with the same name as the local"
307
+ fails "A nested method definition creates a method in the surrounding context when evaluated in a def expr.method"
308
+ fails "The def keyword within a closure looks outside the closure for the visibility"
291
309
  end
@@ -45,4 +45,6 @@ opal_filter "freezing" do
45
45
  fails "String#clone copies frozen state"
46
46
  fails "String#initialize with no arguments does not raise an exception when frozen"
47
47
  fails "StringScanner#initialize returns an instance of StringScanner"
48
+ fails "A singleton method definition raises RuntimeError if frozen"
49
+ fails "A method definition inside a metaclass scope raises RuntimeError if frozen"
48
50
  end
@@ -134,4 +134,12 @@ opal_filter "private" do
134
134
  fails "OpenStruct#initialize is private"
135
135
  fails "OpenStruct#new_ostruct_member is protected"
136
136
  fails "OpenStruct#table is protected"
137
+ fails "Defining a method at the top-level defines it on Object with private visibility by default"
138
+ fails "Defining an 'initialize' method sets the method's visibility to private"
139
+ fails "Defining an 'initialize_copy' method sets the method's visibility to private"
140
+ fails "Defining an 'initialize_dup' method sets the method's visibility to private"
141
+ fails "Defining an 'initialize_clone' method sets the method's visibility to private"
142
+ fails "Defining a 'respond_to_missing?' method sets the method's visibility to private"
143
+ fails "Redefining a singleton method does not inherit a previously set visibility"
144
+ fails "Redefining a singleton method does not inherit a previously set visibility"
137
145
  end
@@ -0,0 +1,19 @@
1
+ # regression test
2
+ describe 'mlhs argument' do
3
+ context 'when pased value is falsey in JS' do
4
+ it 'still returns it' do
5
+ p = ->((a)){ a }
6
+ p.call(false).should == false
7
+ p.call("").should == ""
8
+ p.call(0).should == 0
9
+ end
10
+ end
11
+
12
+ context 'when passed value == null' do
13
+ it 'replaces it with nil' do
14
+ p = ->((a)){ a }
15
+ p.call([`undefined`]).should == nil
16
+ p.call([`null`]).should == nil
17
+ end
18
+ end
19
+ end
data/spec/ruby_specs CHANGED
@@ -94,7 +94,6 @@ ruby/core/unboundmethod
94
94
 
95
95
  ruby/language
96
96
  !ruby/language/constants_spec
97
- !ruby/language/def_spec
98
97
  !ruby/language/execution_spec
99
98
  !ruby/language/hash_spec
100
99
  !ruby/language/next_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.10.0.beta1
4
+ version: 0.10.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Beynon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sourcemap
@@ -691,6 +691,7 @@ files:
691
691
  - spec/opal/core/kernel/respond_to_spec.rb
692
692
  - spec/opal/core/kernel/send_spec.rb
693
693
  - spec/opal/core/kernel/sprintf_spec.rb
694
+ - spec/opal/core/language/arguments/mlhs_arg_spec.rb
694
695
  - spec/opal/core/language/block_spec.rb
695
696
  - spec/opal/core/language/class_spec.rb
696
697
  - spec/opal/core/language/equal_spec.rb
@@ -1354,6 +1355,7 @@ test_files:
1354
1355
  - spec/opal/core/kernel/respond_to_spec.rb
1355
1356
  - spec/opal/core/kernel/send_spec.rb
1356
1357
  - spec/opal/core/kernel/sprintf_spec.rb
1358
+ - spec/opal/core/language/arguments/mlhs_arg_spec.rb
1357
1359
  - spec/opal/core/language/block_spec.rb
1358
1360
  - spec/opal/core/language/class_spec.rb
1359
1361
  - spec/opal/core/language/equal_spec.rb