-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdiagonal_test.go
54 lines (44 loc) · 1.36 KB
/
diagonal_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
package turing
import (
"strings"
"testing"
)
func TestFirstCircularDN(t *testing.T) {
_, err := NewMachineFromDescriptionNumber(DescriptionNumber("1"))
if err == nil {
t.Error("expecting D.N. 1 to be circular")
}
}
func TestFirstCircleFreeDN(t *testing.T) {
machineInput, err := NewMachineFromDescriptionNumber(DescriptionNumber("731332531"))
if err != nil {
t.Error(err)
}
m := NewMachine(machineInput)
m.MoveN(100)
checkTape(t, m.TapeString(), "S1S1S1S1S1S1S1")
}
func TestWellDefinedness(t *testing.T) {
m := NewMachine(NewAbbreviatedTable(AbbreviatedTableInput{
MConfigurations: wellDefinedMachineMConfigurations,
Tape: strings.Split("; D A D A D A D", ""),
StartingMConfiguration: "b",
PossibleSymbols: wellDefinedMachinePossibleSymbols,
}))
m.MoveN(100000)
if m.TapeString()[0] != 'u' {
t.Errorf("expecting unsatisfactory but got %s", m.TapeString())
}
m = NewMachine(NewAbbreviatedTable(AbbreviatedTableInput{
MConfigurations: wellDefinedMachineMConfigurations,
Tape: strings.Split("; D A D D C R D A", ""),
StartingMConfiguration: "b",
PossibleSymbols: wellDefinedMachinePossibleSymbols,
}))
m.MoveN(100000)
if m.TapeString()[0] != 's' {
t.Errorf("expecting satisfactory but got %s", m.TapeString())
}
}
// TODO: Test non-`D` part of `H`
// TODO: Test `M1`, `M2`, etc.