def test_assign_nxt(self): """Test parsing assignment statement.""" ast = parse("x = !true;", p.Assign) c = compose(ast, indent=" ", autoblank=False) s = ast.to_simple() self.assertEqual("x = !true;", c) self.assertEqual(Assign('x', Not(Boolean(True))), s)
def test_or_nxy(self): """Test parsing logical or expression !x || y.""" ast = parse("!x || y", p.Expression) c = compose(ast, indent=" ", autoblank=False) e = ast.to_simple() self.assertEqual("!x || y", c) self.assertEqual(Or(Not(Variable('x')), Variable('y')), e)
def test_not_1p1(self): """Test parsing logical negation expression !1.1.""" ast = parse("!1.1", p.Expression) c = compose(ast, indent=" ", autoblank=False) e = ast.to_simple() self.assertEqual("!1.1", c) self.assertEqual(Not(Number(1.1)), e)
def test_not_x(self): """Test parsing logical negation expression !x.""" ast = parse("!x", p.Expression) c = compose(ast, indent=" ", autoblank=False) e = ast.to_simple() self.assertEqual("!x", c) self.assertEqual(Not(Variable('x')), e)
def test_not_false(self): """Test parsing logical negation expression !false.""" ast = parse("!false", p.Expression) c = compose(ast, indent=" ", autoblank=False) e = ast.to_simple() self.assertEqual("!false", c) self.assertEqual(Not(Boolean(False)), e)
def test_and_xny(self): """Test parsing logical and expression x && !y.""" ast = parse("x && !y", p.Expression) c = compose(ast, indent=" ", autoblank=False) e = ast.to_simple() self.assertEqual("x && !y", c) self.assertEqual(And(Variable('x'), Not(Variable('y'))), e)