parsanol 1.3.122 → 1.3.124

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: 4a2162ac62e96201b3ab45cba32e5b69f8162ec37b266a52fa5be0b16e85823f
4
- data.tar.gz: db0e6ef317d68d558eb06e36b0fcbe50b1f556786065d87dd599154671d8df73
3
+ metadata.gz: fd3371b993b77e992ef44c6a12c46460595e88be97b77dadbcef91d891f2edd0
4
+ data.tar.gz: 90780bf0b7e04e9afcec6910327df787d97bb32658e9a4963e9d70c7dc79890a
5
5
  SHA512:
6
- metadata.gz: 7bdb62867da115b8372fd37b2f4532d44ad48e47571c1aab897845313b4f6bf585aa25e1efcf386aba83305c610256f871c7a5052c631e0c085a03ab1b85560b
7
- data.tar.gz: dbfdf3281e65e86abba50653461bb572c4246499bf8a629b269c4898fc824f8b951714db3bb3a48e5609cecb72d9d10230ac571c73575be195a66d95105ec595
6
+ metadata.gz: a85f8d30e83a3ae06d7161e7a3193a4f476f46c32c84e7b4083d6308c486ee21cc69cca41c125b030e6a4330702e0396a0e6563f51643757f366a892fd8e24f8
7
+ data.tar.gz: d55182b8bf7ae973aeaa5ccb20b22f0bd7c4e7c878272d6cf42acc88ff0e0c5e87d4b2426bac4ab8e963f10642a69c2f07b052ca88c1bb34343c5d50be9ef50c
@@ -241,6 +241,7 @@ module Parsanol
241
241
  end
242
242
  "test #{hash['input'].inspect}: expected captures " \
243
243
  "#{mismatched.transform_values(&:inspect).inspect}, got #{actuals.inspect}"
244
+ when "bind" then bind_mismatch(entry_name, shape, hash)
244
245
  end
245
246
  rescue Parsanol::ParseFailed
246
247
  unless hash["kind"] == "reject"
@@ -250,6 +251,20 @@ module Parsanol
250
251
  end
251
252
  end
252
253
 
254
+ # parsanol-ruby#414: the whole bound map must equal the expectation
255
+ # exactly (not the partial `example` match) — the grammar author
256
+ # pins what the bindings produce, including absent keys and
257
+ # phantom rows.
258
+ def bind_mismatch(entry_name, shape, hash)
259
+ bound = apply_bindings(entry_name, shape)
260
+ actual = Bindings.canonical(bound)
261
+ expected = Bindings.canonical(hash["expect"])
262
+ return nil if actual == expected
263
+
264
+ "test #{hash['input'].inspect}: expected bound #{expected.inspect}, " \
265
+ "got #{actual.inspect}"
266
+ end
267
+
253
268
  # Best-effort recovery (TODO.sota/1, R1): on success returns
254
269
  # {"ok": true, "shape": tree}; on ParseFailed returns
255
270
  # {"ok": false, "error": {"offset", "message"}, "captures":
@@ -15,8 +15,14 @@ module Parsanol
15
15
  captures = collect_captures(shape)
16
16
  # Snapshot before the assignment pass: reading a missing key off
17
17
  # `captures` inserts it (default-proc hash), which would make the
18
- # #413 lost-check below see phantom presence.
19
- present = captures.keys
18
+ # #413 lost-check below see phantom presence. Presence means a
19
+ # NON-NIL value somewhere in the tree: a fired-but-empty optional
20
+ # capture binds null in the parslet shape, and binding nothing for
21
+ # null is legitimate optionality, not loss (parsanol-ruby#418 —
22
+ # CIE trailing_lang, JIS reaffirmed).
23
+ present = captures.keys.select do |key|
24
+ captures[key].any? { |value| !value.nil? }
25
+ end
20
26
  out = {}
21
27
  scalar, arrays = bindings.partition { |binding| !binding["path"].to_s.include?("[]") }
22
28
  scalar.each do |binding|
@@ -11,9 +11,9 @@ module Parsanol
11
11
  # `capture` = phase 1 (grammar layer): asserts the raw capture tree,
12
12
  # no bindings section needed. `example` = phase 2 (bindings layer):
13
13
  # asserts the bound, preprocessed attribute hash.
14
- TEST_KINDS = %i[accept reject example capture shape].freeze
14
+ TEST_KINDS = %i[accept reject example capture shape bind].freeze
15
15
  # Test kinds whose expectations are `{ key: value }` pairs.
16
- PAIR_KINDS = %w[example capture].freeze
16
+ PAIR_KINDS = %w[example capture bind].freeze
17
17
 
18
18
  Test = Struct.new(:entry, :kind, :input, :expect)
19
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.122"
4
+ VERSION = "1.3.124"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsanol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.122
4
+ version: 1.3.124
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.