本文整理匯總了Python中machine.Machine.next方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.next方法的具體用法?Python Machine.next怎麽用?Python Machine.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類machine.Machine
的用法示例。
在下文中一共展示了Machine.next方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_machine_next
# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import next [as 別名]
def test_machine_next(self):
r1 = Rule("A", 0, 1, True, "B")
r2 = Rule("A", 1, 1, True, "A")
r3 = Rule("B", 0, 0, False, "B")
m = Machine(rules=[r1, r2, r3])
write_symbol, shift_right = m.next(1)
self.assertEqual(m.state, "A")
self.assertEqual(write_symbol, 1)
self.assertEqual(shift_right, True)
write_symbol, shift_right = m.next(0)
self.assertEqual(m.state, "B")
self.assertEqual(write_symbol, 1)
self.assertEqual(shift_right, True)
write_symbol, shift_right = m.next(0)
self.assertEqual(m.state, "B")
self.assertEqual(write_symbol, 0)
self.assertEqual(shift_right, False)
with self.assertRaises(Halt):
write_symbol, shift_right = m.next(1)