示例#1
0
def test_actions():
    a = Actions(
        'dot(state, A) --> state=B',
        'dot(state, B) --> state=A',
        default='1.0 --> state=C',
    )
    assert a.count == 3

    model = spa.SPA()
    with model:
        model.state = spa.State(16)
    a.process(model)
    assert str(a.actions[0].condition) == 'dot(state, A)'
    assert str(a.actions[0].effect) == 'state=B'
    assert str(a.actions[1].condition) == 'dot(state, B)'
    assert str(a.actions[1].effect) == 'state=A'
    assert str(a.actions[2].condition) == '1.0'
    assert str(a.actions[2].effect) == 'state=C'

    a.add('dot(state, D) --> state=E')
    a.add(added='dot(state, E) --> state=F')
    a.process(model)
    assert str(a.actions[2].condition) == 'dot(state, D)'
    assert str(a.actions[2].effect) == 'state=E'
    assert str(a.actions[3].condition) == 'dot(state, E)'
    assert str(a.actions[3].effect) == 'state=F'
示例#2
0
def test_actions():
    a = Actions(
        'dot(state, A) --> state=B',
        'dot(state, B) --> state=A',
        default='1.0 --> state=C',
    )
    assert a.count == 3

    model = spa.SPA()
    with model:
        model.state = spa.State(16)
    a.process(model)
    assert str(a.actions[0].condition) == 'dot(state, A)'
    assert str(a.actions[0].effect) == 'state=B'
    assert str(a.actions[1].condition) == 'dot(state, B)'
    assert str(a.actions[1].effect) == 'state=A'
    assert str(a.actions[2].condition) == '1.0'
    assert str(a.actions[2].effect) == 'state=C'

    a.add('dot(state, D) --> state=E')
    a.add(added='dot(state, E) --> state=F')
    a.process(model)
    assert str(a.actions[2].condition) == 'dot(state, D)'
    assert str(a.actions[2].effect) == 'state=E'
    assert str(a.actions[3].condition) == 'dot(state, E)'
    assert str(a.actions[3].effect) == 'state=F'
示例#3
0
def test_actions():
    a = Actions(
        "dot(state, A) --> state=B",
        "dot(state, B) --> state=A",
        default="1.0 --> state=C",
    )
    assert a.count == 3

    model = spa.SPA()
    with model:
        model.state = spa.State(16)
    a.process(model)
    assert str(a.actions[0].condition) == "dot(state, A)"
    assert str(a.actions[0].effect) == "state=B"
    assert str(a.actions[1].condition) == "dot(state, B)"
    assert str(a.actions[1].effect) == "state=A"
    assert str(a.actions[2].condition) == "1.0"
    assert str(a.actions[2].effect) == "state=C"

    a.add("dot(state, D) --> state=E")
    a.add(added="dot(state, E) --> state=F")
    a.process(model)
    assert str(a.actions[2].condition) == "dot(state, D)"
    assert str(a.actions[2].effect) == "state=E"
    assert str(a.actions[3].condition) == "dot(state, E)"
    assert str(a.actions[3].effect) == "state=F"
示例#4
0
def test_actions():
    a = Actions(
        'dot(state, A) --> state=B',
        'dot(state, B) --> state=A',
        default='1.0 --> state=C',
    )
    assert a.count == 3

    class Test(spa.SPA):
        def __init__(self):
            self.state = spa.Buffer(16)

    model = Test()
    a.process(model)
    assert str(a.actions[0].condition) == 'dot(state, A)'
    assert str(a.actions[0].effect) == 'state=B'
    assert str(a.actions[1].condition) == 'dot(state, B)'
    assert str(a.actions[1].effect) == 'state=A'
    assert str(a.actions[2].condition) == '1.0'
    assert str(a.actions[2].effect) == 'state=C'
示例#5
0
def test_actions():
    a = Actions(
        'dot(state, A) --> state=B',
        'dot(state, B) --> state=A',
        default='1.0 --> state=C',
    )
    assert a.count == 3

    class Test(spa.SPA):
        def __init__(self):
            self.state = spa.Buffer(16)

    model = Test()
    a.process(model)
    assert str(a.actions[0].condition) == 'dot(state, A)'
    assert str(a.actions[0].effect) == 'state=B'
    assert str(a.actions[1].condition) == 'dot(state, B)'
    assert str(a.actions[1].effect) == 'state=A'
    assert str(a.actions[2].condition) == '1.0'
    assert str(a.actions[2].effect) == 'state=C'