public void RecordValue2ResultVariables()
        {
            var index = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var seen  = DeclarableParameter.CreateDeclarableParameterExpression(typeof(bool));
            var s1    = new StatementRecordValue(index, new ValSimple("i", typeof(int)), seen, true);

            var index2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));

            s1.AddNewSaver(index2, new ValSimple("j", typeof(int)));

            Assert.AreEqual(3, s1.ResultVariables.Count());
            Assert.AreEqual(1, s1.DependentVariables.Count());
        }
        public void RecordValue2ResultVariablesWith2Dependents()
        {
            var index = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var seen  = DeclarableParameter.CreateDeclarableParameterExpression(typeof(bool));
            var dep1  = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var s1    = new StatementRecordValue(index, dep1, seen, true);

            var index2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var dep2   = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));

            s1.AddNewSaver(index2, dep2);

            Assert.AreEqual(3, s1.ResultVariables.Count());
            Assert.AreEqual(3, s1.DependentVariables.Count());
        }
        public void TestMultipleSavers()
        {
            var index1 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var seen1  = DeclarableParameter.CreateDeclarableParameterExpression(typeof(bool));
            var index2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var seen2  = DeclarableParameter.CreateDeclarableParameterExpression(typeof(bool));
            var index3 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var index4 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int));
            var s1     = new StatementRecordValue(index1, new ValSimple("i", typeof(int)), seen1, true);

            s1.AddNewSaver(index3, new ValSimple("j", typeof(int)));
            var s2 = new StatementRecordValue(index2, new ValSimple("i", typeof(int)), seen2, true);

            s2.AddNewSaver(index4, new ValSimple("j", typeof(int)));

            var dop = new DummyTrackingOptimizationService();

            Assert.IsTrue(s1.TryCombineStatement(s2, dop), "Combined 2 multi-saver guys");

            Assert.AreEqual(3, dop._renameRequests.Count, "# of rename requests");
            Assert.AreEqual(Tuple.Create(index2.RawValue, index1.RawValue), dop._renameRequests[0], "first rename");
            Assert.AreEqual(Tuple.Create(index4.RawValue, index3.RawValue), dop._renameRequests[1], "second rename");
        }