def test_parse_operator(self): assert (self.parser.parse('not a') == term_builder.build_combination(self.not_, qterm.Variable('a', qbool()))) assert (self.parser.parse('a:obj = b:obj') == term_builder.build_binary_op(self.equals, qterm.Variable('a', qobj()), qterm.Variable('b', qobj())))
def test_parse_function(self): t = qfun(qobj(), qobj()) f = qterm.Variable('f', t) g = qterm.Variable('g', t) h = qterm.Variable('h', qfun(qobj(), t)) x = qterm.Variable('x', qobj()) y = qterm.Variable('y', qobj()) assert_equal(self.parser.parse('f:obj->obj(x)'), term_builder.build_combination(f, x)) assert (self.parser.parse('f:obj->obj(g:obj->obj(x))') == term_builder.build_combination(f, term_builder.build_combination(g, x))) assert (self.parser.parse('h:obj->obj->obj(x, y)') == term_builder.build_binary_op(h, x, y))