Tue, 27 Oct 2015 19:36:17 +0000
scansion.generator: Initial basic lib to generate test scripts
9
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | local stanzacmp = require "scansion.stanzacmp"; |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | local verse = require "verse"; |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | local st = require "util.stanza"; |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | local function yes(s1, s2) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | if not stanzacmp.stanzas_match(s1, s2) then |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | print("s1", s1) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | print("s2", s2) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | print("literal", tostring(s1) == tostring(s2)); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | assert(false, "No match, but they should."); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | end |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | end |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | local function no(s1, s2) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | if stanzacmp.stanzas_match(s1, s2) then |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | print("s1", s1) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | print("s2", s2) |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | assert(false, "Match, but they should not."); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | end |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | end |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | local s1 = st.message({ to = "foo", from = "bar"}); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | local s2 = st.message({ to = "foo", from = "bar"}); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | yes(s2, s1); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | s1.attr.to = nil; |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | no(s2, s1); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | s1.attr.to = "foo"; |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | s2:tag("blah", { xmlns = "foobar" }); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 | no(s2, s1); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | s1:tag("blah", { xmlns = "foobar" }); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | yes(s2, s1); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | s1:tag("a"); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | no(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | s2:tag("a"); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 | s2:up():up(); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 | s2:tag("extension", { xmlns = "blah" }); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | s2:tag("b"); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 | s1:up():up(); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 | s1:tag("extension", { xmlns = "blah" }); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | no(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | s1:tag("b"); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | yes(s1, s2); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | s1:tag("c", { n = "1" }); |
15e9d47941bd
testcmp: Small script to test stanzacmp works as expected
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | no(s1, s2); |