当前位置: 首页>>代码示例>>Python>>正文


Python TransitionTable.addTerminalState方法代码示例

本文整理汇总了Python中machinist.TransitionTable.addTerminalState方法的典型用法代码示例。如果您正苦于以下问题:Python TransitionTable.addTerminalState方法的具体用法?Python TransitionTable.addTerminalState怎么用?Python TransitionTable.addTerminalState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在machinist.TransitionTable的用法示例。


在下文中一共展示了TransitionTable.addTerminalState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_addTerminalState

# 需要导入模块: from machinist import TransitionTable [as 别名]
# 或者: from machinist.TransitionTable import addTerminalState [as 别名]
 def test_addTerminalState(self):
     """
     L{TransitionTable.addTerminalState} returns a L{TransitionTable} that
     includes the given state in its table with no transitions defined.
     """
     table = TransitionTable()
     more = table.addTerminalState("foo")
     self.assertEqual({"foo": {}}, more.table)
开发者ID:ClusterHQ,项目名称:machinist,代码行数:10,代码来源:test_fsm.py

示例2: test_nextStateNotMissingIfInitial

# 需要导入模块: from machinist import TransitionTable [as 别名]
# 或者: from machinist.TransitionTable import addTerminalState [as 别名]
    def test_nextStateNotMissingIfInitial(self):
        """
        L{MissingTransitionNextState} is not raised if a value defined by
        C{state} appears nowhere in C{transitions} as a next state but is given
        as C{initial}.
        """
        transitions = TransitionTable()
        transitions = transitions.addTransition(
            MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
        transitions = transitions.addTerminalState(MoreState.blue)

        constructFiniteStateMachine(
            Input, Output, MoreState, transitions,
            MoreState.blue, [], {}, NULL_WORLD)
开发者ID:ClusterHQ,项目名称:machinist,代码行数:16,代码来源:test_fsm.py

示例3: test_missingTransitionNextState

# 需要导入模块: from machinist import TransitionTable [as 别名]
# 或者: from machinist.TransitionTable import addTerminalState [as 别名]
    def test_missingTransitionNextState(self):
        """
        L{MissingTransitionNextState} is raised if any of the values defined by
        C{state} appears nowhere in C{transitions} as a next state.
        """
        transitions = TransitionTable()
        transitions = transitions.addTransition(
            MoreState.amber, Input.apple, [Output.aardvark], MoreState.amber)
        transitions = transitions.addTerminalState(MoreState.blue)

        exc = self.assertRaises(
            MissingTransitionNextState,
            constructFiniteStateMachine,
            Input, Output, MoreState, transitions,
            MoreState.amber, [], {}, NULL_WORLD)
        self.assertEqual(({MoreState.blue},), exc.args)
开发者ID:ClusterHQ,项目名称:machinist,代码行数:18,代码来源:test_fsm.py

示例4: IFood

# 需要导入模块: from machinist import TransitionTable [as 别名]
# 或者: from machinist.TransitionTable import addTerminalState [as 别名]
class IFood(Interface):
    radius = Attribute("The radius of the food (all food is spherical)")



@implementer(IFood)
class Gravenstein(trivialInput(Input.apple)):
    # Conveniently, apples are approximately spherical.
    radius = 3



TRANSITIONS = TransitionTable()
TRANSITIONS = TRANSITIONS.addTransition(
    MoreState.amber, Input.apple, [Output.aardvark], MoreState.blue)
TRANSITIONS = TRANSITIONS.addTerminalState(MoreState.blue)


class FiniteStateMachineTests(TestCase):
    """
    Tests for the L{IFiniteStateMachine} provider returned by
    L{constructFiniteStateMachine}.
    """
    def setUp(self):
        self.animals = []
        self.initial = MoreState.amber

        self.world = AnimalWorld(self.animals)
        self.fsm = constructFiniteStateMachine(
            Input, Output, MoreState, TRANSITIONS, self.initial,
            [Gravenstein], {Output.aardvark: IFood},
开发者ID:ClusterHQ,项目名称:machinist,代码行数:33,代码来源:test_fsm.py


注:本文中的machinist.TransitionTable.addTerminalState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。