-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathprettyprinter_test.go
35 lines (32 loc) · 970 Bytes
/
prettyprinter_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
package quamina
import (
"testing"
)
func TestPP(t *testing.T) {
pp := newPrettyPrinter(1)
table, _ := makeShellStyleFA([]byte(`"x*9"`), pp)
pp.labelTable(table, "START HERE")
wanted := ` 758[START HERE] '22/"' → 910[on " at 0]
910[on " at 0] '78/x' → 821[gS at 2]
821[gS at 2] ε → 821[gS at 2] / '39/9' → 551[gX on 9 at 3]
551[gX on 9 at 3] '22/"' → 937[on " at 4]
937[on " at 4] 'f5/ℵ' → 820[last step at 5]
820[last step at 5] [1 transition(s)]
`
s := pp.printNFA(table)
if s != wanted {
t.Errorf("LONG: wanted\n<%s>\ngot\n<%s>\n", wanted, s)
}
if pp.shortPrintNFA(table) != "758[START HERE]" {
t.Errorf("SHORT: wanted <%s> got <%s>\n", "758[START HERE]", pp.shortPrintNFA(table))
}
}
func TestNullPP(t *testing.T) {
np := &nullPrinter{}
table := newSmallTable()
table.addByteStep(3, &faNext{})
np.labelTable(table, "foo")
if np.printNFA(table) != noPP || np.shortPrintNFA(table) != noPP {
t.Error("didn't get noPP")
}
}