-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtnt_test.go
70 lines (65 loc) · 1.58 KB
/
tnt_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package tnt
import (
"testing"
)
func TestWellFormed(t *testing.T) {
for _, wellFormed := range []string{
"0=0",
"~0=0",
"<0=0^0=0>",
"<a=b^b=c>",
"~<a=b^b=c>",
"Aa:Eb:<a=b^b=c>",
"Eb:b=a",
} {
formula, err := ParseFormula(wellFormed)
if err != nil {
t.Errorf("error parsing %q: %s", wellFormed, err)
} else if !formula.WellFormed() {
t.Errorf("expected %q to be well formed", wellFormed)
}
}
for _, notWellFormed := range []string{
"<Aa:a=a^a=a>", // a quantified on left, but not right
"~<Aa:a=a^a=a>", // negation of above
"<a=a^Aa:a=a>", // a quantified on right, but not left
"~<a=a^Aa:a=a>", // negation of above
"Eb:<Aa:a=a^a=b>", // quantification of above
"Aa:0=0", // a is not free
"Ea:Aa:a=0", // a is quantified twice
} {
formula, err := ParseFormula(notWellFormed)
if err != nil {
t.Errorf("error parsing %q: %s", notWellFormed, err)
} else if formula.WellFormed() {
t.Errorf("expected %q to be not well formed", notWellFormed)
}
}
}
func TestOpen(t *testing.T) {
for _, open := range []string{
"a=b",
"(a+b)=0",
"~(a+b)=0",
"S(a+b)=0",
} {
formula, err := ParseFormula(open)
if err != nil {
t.Errorf("error parsing %q: %s", open, err)
} else if !formula.Open() {
t.Errorf("expected %q to be open", open)
}
}
for _, closed := range []string{
"S0=0",
"Aa:Eb:(a+b)=0",
"~Aa:Eb:(a+b)=0",
} {
formula, err := ParseFormula(closed)
if err != nil {
t.Errorf("error parsing %q: %s", closed, err)
} else if formula.Open() {
t.Errorf("expected %q to be closed", closed)
}
}
}