def test_nx():
    g = nx.DiGraph()
    g.inputs = {'a': '...', 'b': '...'}
    g.outputs = {'c': '...', 'd': '...'}
    start = 'Sinit'
    g.add_edge(start, 0, a=0, b=0, c=0, d=0)
    g.add_edge(0, 1, a=0, b=1, c=0, d=1)
    g.add_edge(1, 2, a=1, b=0, c=1, d=1)
    print(dumpsmach.python_case(g, classname='Machine', start='Sinit'))
    exe_globals = dict()
    exec(dumpsmach.python_case(g, classname='Machine', start='Sinit'), exe_globals)
    m = exe_globals['Machine']()
    out = m.move(a=0, b=0)
    assert (out == dict(c=0, d=0))
    out = m.move(a=0, b=1)
    assert (out == dict(c=0, d=1))
    with assert_raises(ValueError):
        m.move(a=1, b=1)
    out = m.move(a=1, b=0)
    assert (out == dict(c=1, d=1))
    with assert_raises(Exception):
        m.move(a=1, b=0)
def test_nx():
    g = nx.DiGraph()
    g.inputs = {'a': '...', 'b': '...'}
    g.outputs = {'c': '...', 'd': '...'}
    start = 'Sinit'
    g.add_edge(start, 0, a=0, b=0, c=0, d=0)
    g.add_edge(0, 1, a=0, b=1, c=0, d=1)
    g.add_edge(1, 2, a=1, b=0, c=1, d=1)
    print(dumpsmach.python_case(g, classname='Machine', start='Sinit'))
    exe_globals = dict()
    exec(dumpsmach.python_case(g, classname='Machine', start='Sinit'), exe_globals)
    m = exe_globals['Machine']()
    out = m.move(a=0, b=0)
    assert (out == dict(c=0, d=0))
    out = m.move(a=0, b=1)
    assert (out == dict(c=0, d=1))
    with assert_raises(ValueError):
        m.move(a=1, b=1)
    out = m.move(a=1, b=0)
    assert (out == dict(c=1, d=1))
    with assert_raises(Exception):
        m.move(a=1, b=0)