diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-04-04 22:27:13 +1200 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-04-04 22:27:13 +1200 |
| commit | 0e72ca7037007d75dd4d02a1c9f7805a49e8414e (patch) | |
| tree | f4c797a556833cb7e38b9350e43ad0506fed855d /spec/practical/int_int_hash_spec.cr | |
| parent | c98c2b5dba76a64f51fc4dfba279cd616e3338ad (diff) | |
Test case now matches walkthough final code
Diffstat (limited to 'spec/practical/int_int_hash_spec.cr')
| -rw-r--r-- | spec/practical/int_int_hash_spec.cr | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/spec/practical/int_int_hash_spec.cr b/spec/practical/int_int_hash_spec.cr index 4d4ce0c..d9b256d 100644 --- a/spec/practical/int_int_hash_spec.cr +++ b/spec/practical/int_int_hash_spec.cr @@ -3,7 +3,6 @@ require "../spec_helper" include Parcom describe "Hash(Int32, Int32) parser", tags: "example" do - # setup d = Parser(Char, Char).satisfy(&.number?).named("digit") abs_num = d.some.map { |ds| ds.join.to_i32 }.named("abs_num") @@ -12,7 +11,7 @@ describe "Hash(Int32, Int32) parser", tags: "example" do int32 = parser_chain Char, Int32, "int32", {s, sign}, {n, abs_num}, - pure: n * s + pure: n * s ws = Parser(Char, Char).satisfy(&.whitespace?) .many @@ -28,10 +27,7 @@ describe "Hash(Int32, Int32) parser", tags: "example" do delim = (ws >> Parser.token(',') >> ws).named("delim") - elements = parser_chain Char, Array({Int32, Int32}), "elements", - {pairs, pair.sep_by(delim)}, - {_, delim.optional}, # trailing comma - pure: pairs + elements = (pair.sep_by(delim) << delim.optional).named("elements") hash_start = (Parser.token('{') >> ws).named("start") hash_end = (ws >> Parser.token('}')).named("end") |
