barefoot_js 0.32.0 → 0.33.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/barefoot_js/evaluator.rb +19 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b3e5b4d4d4a6cbcc72548a569ee6e9dd6b9cc6c94f4a9694333c6a55a312964
4
- data.tar.gz: fb060b34a8fda7a51f99fb600d4830a514cfef423b2d1c50b016f9f788d4a5e0
3
+ metadata.gz: b7f4174e45092095b0751f372692d0d499b410b20ed189b6dade7ac17b6783ab
4
+ data.tar.gz: 3530953234122f800b30c570474f1d8f1983a1a20881e8048f52846c777e54b8
5
5
  SHA512:
6
- metadata.gz: 8dbd3aeb754380544195553abb6dd897aaa14b6ff83fa829fbef1c0c71b9505099b4ff731d13af991b3f1f7b2bafb141a4901db3122e98a46504ea93932dec65
7
- data.tar.gz: 5732ffdbee3ba8029496543a3a27124eb8c4a25b478cca2b6e5d81cc5244ae53100e3e2af19cec69ce38dc7654ecb0c7b396c14a93ebae6d97d5abd26734688b
6
+ metadata.gz: efe2cabddf07f58e24009f81504ee4a3000e9ed42caef5df804f2d060283410279e461e244078d2f3f9746ebd9fca505c5ca740170ac984296dd3320d3988ea9
7
+ data.tar.gz: 2c467d54aff8f44fbf65915c37c0e918fe5fba550cb0d9c2e8357d637a2ab9f1e25be8e894e5775a0ded6921c4323d14a0ba8c13bd8cf2a26c4c56bc980d0de3
@@ -100,8 +100,26 @@ module BarefootJS
100
100
  when 'array-literal'
101
101
  (node[:elements] || []).map { |e| evaluate(e, env) }
102
102
  when 'object-literal'
103
+ # Each entry carries its own `kind` ('prop' | 'spread', #2696 Step
104
+ # 2) -- the same encoding the Go/Perl/Python evaluators and the raw
105
+ # ParsedExpr shape the eval-vectors.json golden corpus carry. A
106
+ # 'spread' evaluates its `expr` and shallow-merges the result's own
107
+ # keys (a non-Hash result -- including a null/undefined JS spread
108
+ # source -- is a no-op). Every hash this evaluator builds uses
109
+ # SYMBOL keys (`read_property` below always looks up `key.to_sym`),
110
+ # so a spread's keys are symbolized on merge for the same reason a
111
+ # `prop` key already is, regardless of whether the spread source's
112
+ # own keys started out as symbols or strings. Later entries win on
113
+ # a shared key, in source order, matching JS object-spread exactly.
103
114
  out = {}
104
- (node[:properties] || []).each { |prop| out[prop[:key].to_sym] = evaluate(prop[:value], env) }
115
+ (node[:properties] || []).each do |prop|
116
+ if (prop[:kind] || '') == 'spread'
117
+ spread = evaluate(prop[:expr], env)
118
+ spread.each { |k, v| out[k.to_sym] = v } if spread.is_a?(Hash)
119
+ next
120
+ end
121
+ out[prop[:key].to_sym] = evaluate(prop[:value], env)
122
+ end
105
123
  out
106
124
  when 'array-method'
107
125
  args = node[:args] || []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barefoot_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.0
4
+ version: 0.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaken