diff -r ecae87f5aaba -r db73c4c317ce spec/stanzacmp_spec.lua --- a/spec/stanzacmp_spec.lua Sat May 08 13:21:56 2021 +0200 +++ b/spec/stanzacmp_spec.lua Thu Mar 23 11:43:25 2023 +0000 @@ -18,9 +18,9 @@ return table.unpack(out, 1, n); end -local function yes(s1, s2) +local function yes(s1, s2, captures) s1, s2 = parse(s1, s2); - if not stanzacmp.stanzas_match(s1, s2) then + if not stanzacmp.stanzas_match(s1, s2, captures) then print("s1", s1) print("s2", s2) print("literal", tostring(s1) == tostring(s2)); @@ -28,9 +28,9 @@ end end -local function no(s1, s2) +local function no(s1, s2, captures) s1, s2 = parse(s1, s2); - if stanzacmp.stanzas_match(s1, s2) then + if stanzacmp.stanzas_match(s1, s2, captures) then print("s1", s1) print("s2", s2) assert(false, "Match, but they should not."); @@ -197,4 +197,28 @@ ]]); end); + + it("supports captures", function () + local captures = {}; + yes([[ + + + + + + ]], + [[ + + + + + + ]], captures); + assert.same({ + ["attr:jid"] = 'user@localhost/KeoGLEr3'; + ["attr:affiliation"] = "owner"; + ["code1"] = "201"; + ["code2"] = "110"; + }, captures); + end); end);