Ejemplo n.º 1
0
        public void TestDeserialize1()
        {
            string code = "a=1;";
            Dictionary <int, List <VariableLine> > unboundIdentifiers = null;
            List <ProtoCore.AST.Node> astNodes = null;

            GraphUtilities.ParseCodeBlockNodeStatements(code, unboundIdentifiers, out astNodes);

            Ui.Statement statement = new Ui.Statement(astNodes[0]);

            IStorage storage = new BinaryStorage();

            statement.Serialize(storage);
            Ui.Statement newStatement = new Ui.Statement(storage);
            storage.Seek(0, SeekOrigin.Begin);
            newStatement.Deserialize(storage);

            VariableSlotInfo outputExpression = new VariableSlotInfo("a", 1, uint.MaxValue);

            Assert.AreEqual("a", statement.DefinedVariable);
            Assert.AreEqual(outputExpression, statement.OutputExpression);
            Assert.AreEqual(0, statement.References.Count);
            Assert.AreEqual(0, statement.Children.Count);
            Assert.AreEqual(false, statement.IsSwappable);
            Assert.AreEqual(false, statement.IsComplex);
        }
Ejemplo n.º 2
0
        public void TestConstructor3()
        {
            string code = "a[1][2] = 1;";
            Dictionary <int, List <VariableLine> > unboundIdentifiers = null;
            List <ProtoCore.AST.Node> astNodes = null;

            GraphUtilities.ParseCodeBlockNodeStatements(code, unboundIdentifiers, out astNodes);

            Ui.Statement statement = new Ui.Statement(astNodes[0]);

            VariableSlotInfo outputExpression = new VariableSlotInfo("a[1][2].x[2].p", 1, uint.MaxValue);

            Assert.AreEqual("a", statement.DefinedVariable);
            Assert.AreEqual(outputExpression, statement.OutputExpression);
            Assert.AreEqual(0, statement.References.Count);
            Assert.AreEqual(0, statement.Children.Count);
            Assert.AreEqual(false, statement.IsSwappable);
            Assert.AreEqual(false, statement.IsComplex);
        }