|
1 local stanzacmp = require "scansion.stanzacmp"; |
|
2 local verse = require "verse"; |
|
3 local st = require "util.stanza"; |
|
4 |
|
5 local function yes(s1, s2) |
|
6 if not stanzacmp.stanzas_match(s1, s2) then |
|
7 print("s1", s1) |
|
8 print("s2", s2) |
|
9 print("literal", tostring(s1) == tostring(s2)); |
|
10 assert(false, "No match, but they should."); |
|
11 end |
|
12 end |
|
13 |
|
14 local function no(s1, s2) |
|
15 if stanzacmp.stanzas_match(s1, s2) then |
|
16 print("s1", s1) |
|
17 print("s2", s2) |
|
18 assert(false, "Match, but they should not."); |
|
19 end |
|
20 end |
|
21 |
|
22 local s1 = st.message({ to = "foo", from = "bar"}); |
|
23 local s2 = st.message({ to = "foo", from = "bar"}); |
|
24 |
|
25 yes(s1, s2); |
|
26 yes(s2, s1); |
|
27 |
|
28 s1.attr.to = nil; |
|
29 |
|
30 yes(s1, s2); |
|
31 no(s2, s1); |
|
32 |
|
33 s1.attr.to = "foo"; |
|
34 yes(s1, s2); |
|
35 |
|
36 s2:tag("blah", { xmlns = "foobar" }); |
|
37 |
|
38 yes(s1, s2); |
|
39 no(s2, s1); |
|
40 |
|
41 s1:tag("blah", { xmlns = "foobar" }); |
|
42 yes(s1, s2); |
|
43 yes(s2, s1); |
|
44 |
|
45 s1:tag("a"); |
|
46 no(s1, s2); |
|
47 s2:tag("a"); |
|
48 yes(s1, s2); |
|
49 s2:up():up(); |
|
50 s2:tag("extension", { xmlns = "blah" }); |
|
51 yes(s1, s2); |
|
52 s2:tag("b"); |
|
53 yes(s1, s2); |
|
54 s1:up():up(); |
|
55 s1:tag("extension", { xmlns = "blah" }); |
|
56 no(s1, s2); |
|
57 s1:tag("b"); |
|
58 yes(s1, s2); |
|
59 s1:tag("c", { n = "1" }); |
|
60 no(s1, s2); |