From 0e72ca7037007d75dd4d02a1c9f7805a49e8414e Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Tue, 4 Apr 2023 22:27:13 +1200 Subject: Test case now matches walkthough final code --- spec/practical/int_int_hash_spec.cr | 8 ++------ 1 file 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") -- cgit v1.2.1