Пример #1
0
        public void TestSimpleRename()
        {
            var array  = DeclarableParameter.CreateDeclarableParameterArrayExpression(typeof(int));
            var index1 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var index2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));

            var st = new StatementPairLoop(array, index1, index2);
            var vr = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));

            vr.RenameRawValue(vr.RawValue, index1.RawValue);
            st.Add(new StatementAssign(vr, new ValSimple("ops", typeof(int))));

            st.RenameVariable(index1.RawValue, "dude1");
            Assert.AreEqual("dude1", index1.RawValue, "index1 after index1 rename");
            Assert.AreEqual("dude1", (st.Statements.First() as StatementAssign).ResultVariable.RawValue, "sub statement not renamed correctly");

            st.RenameVariable(index2.RawValue, "dude2");
            Assert.AreEqual("dude1", index1.RawValue, "index1 after index2 rename");
            Assert.AreEqual("dude2", index2.RawValue, "index1 after index1 rename");

            st.RenameVariable(array.RawValue, "fork");
            Assert.AreEqual("fork", array.RawValue, "array after array rename");
            Assert.AreEqual("dude1", index1.RawValue, "index1 after array rename");
            Assert.AreEqual("dude2", index2.RawValue, "index1 after array rename");
        }
Пример #2
0
 public StatementPairLoop TestRename([PexAssumeUnderTest] StatementPairLoop pairLoop, string oldName, string newName)
 {
     pairLoop.RenameVariable(oldName, newName);
     return(pairLoop);
 }