示例#1
0
def test_backward():
    """ Computation of the fibonnacci series using fast transfer in backward direction """
    l = Lsystem(get_filename('fibonacci.lpy'))
    a = l.iterate()
    print(a)
    assert a[2][0] == 6765, "Lpy failed to compute fibonacci test"
    assert a[3][0] == 4181, "Lpy failed to compute fibonacci test"
    assert a[21][0] == 1, "Lpy failed to compute fibonacci test"
示例#2
0
def test_nproduce(verbose=False):
    """ Test use of nproduce """
    l = Lsystem(get_filename('test_nproduce.lpy'))
    if verbose: print l.axiom
    res = l.derive(1)
    if verbose: print res
    assert len(res) == 2 and res[1].name == 'B'
    res = l.derive(res, 1, 1)
    if verbose: print res
    assert len(res) == 1 and res[0].name == 'C'
    res = l.derive(res, 2, 1)
    if verbose: print res
    assert len(res) == 1 and res[0].name == 'D'
    res = l.derive(res, 3, 1)
    if verbose: print res
    assert len(res) == 0
示例#3
0
def test_selection():
    """ Test customisation of the plot and selection procedure """
    plot = Plotter()
    registerPlotter(plot)
    l = Lsystem(get_filename('test_selection.lpy'))
    ln = len(l.axiom)
    l.context().makeCurrent()
    assert l.axiom == AxialTree('N[+NN][-N]N') and 'Invalid axiom parsing'
    print l.axiom
    res = l.iterate(1)
    print res
    assert len(res) == ln + 1
    assert res[3].name == '%'
    res = l.derive(res, 1, 1)
    print res
    assert len(res) == ln - 2
    assert plot.selectionAsked and "Selection has not been asked"
    l.done()
    cleanPlotter()
示例#4
0
def test_axial_msmatch():
    """ Test matching with axial tree context modification"""
    f = open(get_filename('test_axial_msmatch.lpy'))
    code = f.read()
    f.close()
    matching_run(code, range(2, 4))
示例#5
0
def test_simple_match() : 
    """ Simple matching """
    matching_run(get_filename('test_simple_matching.lpy'))
示例#6
0
def test_enviro():
    """ Test whether environment module ?P works """
    l = Lsystem(get_filename('p_h_enviro.lpy'))
    res = l.iterate()
    assert res[1][0] == Vector3(0, 0,
                                10) and "homomorphism not applied before ?P"
示例#7
0
def test_kwd():
    ''' test matching with **kwd '''
    for optionvalue in [1, 2]:
        l = Lsystem(get_filename('test_kwd.lpy'))
        l.context().options.setSelection('Module matching', optionvalue)
        l.iterate()
示例#8
0
def test_multi_line():
    l = Lsystem(get_filename('test_multiline_produce.lpy'))
    l.iterate()
示例#9
0
def test_group():
    """ Test group of rules """
    l = Lsystem(get_filename('test_group.lpy'))
    l.iterate()