([e.OperatorAtom('ln'), e.Atom('x')], 'ln(x)'), ([e.OperatorAtom('lg'), e.Atom('x')], 'lg(x)'), ([e.OperatorAtom('log'), e.SuperscriptSubscript(subscript=e.ElementList([e.Atom('8')])), e.Atom('x')], 'log_base(8.0,x)'), ([e.OperatorAtom('sin'), e.Atom('3'), e.Atom('x')], 'sin(3.0*x)'), ([e.OperatorAtom('sin'), e.Paren("{"), e.Atom('3'), e.Atom('x'), e.Paren("}"), e.Atom('y')], 'sin(3.0*x)*y'), ([e.OperatorAtom('sin'), e.Paren("{"), e.Atom('3'), e.Atom('x'), e.Paren("}"), e.SuperscriptSubscript( exponent=e.ElementList([e.Atom('3'), e.Atom('z')]) )], 'mypow(sin(3.0*x), (3.0*z))'), ([e.OperatorAtom('sin'), e.Atom('3'), e.BinaryOperatorAtom('-'), e.Atom('x')], 'sin(3.0)-x'), ([e.OperatorAtom('sin'), e.BinaryOperatorAtom('-'), e.Atom('x')], 'sin(-x)'), ([e.Atom('y'), e.Radical([ e.Atom('x'), e.BinaryOperatorAtom('-'), e.Atom('1')])], 'y*sqrt(x-1.0)'), ([e.Atom('y'), e.Radical([ e.Atom('x'), e.BinaryOperatorAtom('-'), e.Atom('1')], index=[e.Atom('3')])], 'y*pow(x-1.0, 1.0/(3.0))'), ]) def test_elementlist_to_glsl(elems, expected): assert e.ElementList(elems).to_glsl() == ('', expected) @pytest.mark.parametrize('string', [
e.Paren("}"), e.Atom('y') ], 'sin(3.0*x)*y'), ([ e.OperatorAtom('sin'), e.Paren("{"), e.Atom('3'), e.Atom('x'), e.Paren("}"), e.SuperscriptSubscript( exponent=e.ElementList([e.Atom('3'), e.Atom('z')])) ], 'mypow(sin(3.0*x), (3.0*z))'), ([ e.OperatorAtom('sin'), e.Atom('3'), e.BinaryOperatorAtom('-'), e.Atom('x') ], 'sin(3.0)-x'), ([e.OperatorAtom('sin'), e.BinaryOperatorAtom('-'), e.Atom('x')], 'sin(-x)'), ([ e.Atom('y'), e.Radical([e.Atom('x'), e.BinaryOperatorAtom('-'), e.Atom('1')]) ], 'y*sqrt(x-1.0)'), ([ e.Atom('y'), e.Radical( [e.Atom('x'), e.BinaryOperatorAtom('-'),
def equals(self, _): return elements.BinaryOperatorAtom("=")
def minus(self, _): return elements.BinaryOperatorAtom("−")
def plus(self, _): return elements.BinaryOperatorAtom("+")
def times(self, _): return elements.BinaryOperatorAtom("×")