Esempio n. 1
0
 def test_string_length(self):
     tape = Tape.fromString("abaabba")
     filename = self.getFile("../../test/xml/string_length_tm.xml")
     table = StatefulTable.fromXMLFile(filename)
     machine = TuringMachine(table, tape)
     machine.run()
     self.assertEqual("7", machine.tape.asPlainString().strip())
Esempio n. 2
0
 def test_add_one(self):
     tape = Tape.fromString("459")
     filename = self.getFile("../../test/xml/add_one_tm.xml")
     table = StatefulTable.fromXMLFile(filename)
     machine = TuringMachine(table, tape)
     machine.run()
     self.assertEqual("460", machine.tape.asPlainString().strip())
Esempio n. 3
0
 def test_palindrome(self):
     tape = Tape.fromString("01210")
     filename = self.getFile("../../test/xml/palindrome_tm.xml")
     table = StatefulTable.fromXMLFile(filename)
     machine = TuringMachine(table, tape)
     machine.run()
     self.assertEqual("", machine.tape.asPlainString().strip())
Esempio n. 4
0
 def test_rot13(self):
     tape = Tape.fromString("abcdefgh$")
     filename = self.getFile("../../test/xml/rot13_tm.xml")
     table = StatefulTable.fromXMLFile(filename)
     machine = TuringMachine(table, tape)
     machine.run()
     self.assertEqual("nopqrstu$", machine.tape.asPlainString().strip())