本文整理汇总了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)