public void CheckType()
        {
            VarNode  varn    = new VarNode("foo", TypeInfo.Int, null);
            IContext context = new Context();

            varn.RegisterInContext(context);
            NameNode     target = new NameNode("foo");
            ConstantNode expr   = new ConstantNode(42);

            AssignmentNode node = new AssignmentNode(target, expr);

            node.CheckType(context);

            Assert.AreSame(TypeInfo.Int, target.TypeInfo);
        }
        public void RaiseIfTypeMismatch()
        {
            IContext context = new Context();
            NameNode target  = new NameNode("foo");

            target.SetTypeInfo(TypeInfo.Double);
            target.RegisterInContext(context);
            ConstantNode expr = new ConstantNode(42);

            AssignmentNode node = new AssignmentNode(target, expr);

            try
            {
                node.CheckType(context);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("type mismatch", ex.Message);
            }
        }