public void TestUnary() { var mult = new Arith(new Token('*'), new Constant(42), new Constant(3)); var u = new Unary(new Token('-'), mult); Assert.AreEqual("- 42 * 3", u.ToString()); Assert.IsTrue(u.Gen() is Expr); }
public void UnaryGenTest() { var token = new Token('-'); var variable = new Id(new Word("x", Tag.ID), VarType.INT, 0); var unary = new Unary(token, variable); var exp = unary.Gen(); Assert.IsInstanceOfType(exp, typeof(Unary)); Assert.AreEqual(VarType.INT, exp.Type); }