Beispiel #1
0
def _tester(tstr, res, funcs=None):
    expr = parse(tstr)
    xtor = ExtractNames()
    xtor.visit(expr)
    eq_(xtor.names, res)
    if funcs:
        eq_(xtor.funcnames, funcs)
Beispiel #2
0
def _tester(tstr, res, funcs=None):
    expr = parse(tstr)
    xtor = ExtractNames()
    xtor.visit(expr)
    eq_(xtor.names, res)
    if funcs:
        eq_(xtor.funcnames, funcs)
Beispiel #3
0
    def test_extractnames(self):
        ss = "-+12354.5678E-12_aoeu"
        expr = parse(ss)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['aoeu'])

        ss2 = ".02808_a123_45"
        expr = parse(ss2)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['a123_45'])

        funccall = parse("foo(a, b-3+x(14), c=d+1)")
        xtor = ExtractNames()
        xtor.visit(funccall)
        eq_(xtor.names, ['a', 'b', 'd'])
        eq_(xtor.funcnames, ['foo', 'x'])

        power = parse("+1**2_a8")
        xtor = ExtractNames()
        xtor.visit(power)
        eq_(xtor.names, ['a8'])
        eq_(xtor.funcnames, [])
Beispiel #4
0
    def test_extractnames(self):
        ss = "-+12354.5678E-12_aoeu"
        expr = parse(ss)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['aoeu'])

        ss2 = ".02808_a123_45"
        expr = parse(ss2)

        xtor = ExtractNames()
        xtor.visit(expr)
        eq_(xtor.names, ['a123_45'])

        funccall = parse("foo(a, b-3+x(14), c=d+1)")
        xtor = ExtractNames()
        xtor.visit(funccall)
        eq_(xtor.names, ['a', 'b', 'd'])
        eq_(xtor.funcnames, ['foo', 'x'])

        power = parse("+1**2_a8")
        xtor = ExtractNames()
        xtor.visit(power)
        eq_(xtor.names, ['a8'])
        eq_(xtor.funcnames, [])