public void CombineOneTwoLevelAndOneOneLevelFunctions2() { var q1 = new GeneratedCode(); var q2 = new GeneratedCode(); var f1 = QMFuncUtils.GenerateFunction(); var r1 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int)); var s1 = new Statements.StatementAssign(r1, new Variables.ValSimple(f1.Name + "()", typeof(int))); var f2 = GenerateFunction2(); var r2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int)); var s2 = new Statements.StatementAssign(r2, new Variables.ValSimple(f2[1].Name + "()", typeof(int))); q1.Add(f1); q1.Add(s1); q1.SetResult(r1); q2.Add(f2[0]); q2.Add(f2[1]); q2.Add(s2); q2.SetResult(r2); var target = new CombinedGeneratedCode(); target.AddGeneratedCode(q1); target.AddGeneratedCode(q2); target.DumpCodeToConsole(); Assert.AreEqual(2, target.Functions.Count(), "# of functions should be combined to 2"); Assert.AreEqual(1, target.QueryCode().Count(), "# of query code blocks"); Assert.AreEqual(2, target.QueryCode().First().Statements.Count(), "# of statements in the combined block."); Assert.IsFalse(target.DumpCode().Where(l => l.Contains(f2[0].Name)).Any(), "The new function was still in there"); }
/// <summary> /// Do the code combination we require! /// </summary> /// <param name="gcs"></param> /// <returns></returns> private IExecutableCode CombineQueries(params IExecutableCode[] gcs) { var combinedInfo = new CombinedGeneratedCode(); foreach (var cq in gcs) { combinedInfo.AddGeneratedCode(cq); } return(combinedInfo); }
internal void CheckAddIncludeFiles([PexAssumeNotNull] string[] incnames) { var cc = new CombinedGeneratedCode(); foreach (var item in incnames) { var gc = new GeneratedCode(); gc.AddIncludeFile(item); cc.AddGeneratedCode(gc); } HashSet<string> unique = new HashSet<string>(incnames); Assert.AreEqual(unique.Count, cc.IncludeFiles.Count(), "wrong # of unqiue names"); }
internal void CheckAddSameVariableNamesToTransfer([PexAssumeNotNull] ROOTNET.NTObject[] varnames) { var cc = new CombinedGeneratedCode(); HashSet<string> unique = new HashSet<string>(); foreach (var item in varnames) { var gc = new GeneratedCode(); var name = gc.QueueForTransfer(item); unique.Add(name); cc.AddGeneratedCode(gc); } Assert.AreEqual(unique.Count, varnames.Length, "there are non-unique names and there are no errors!"); Assert.AreEqual(varnames.Length, cc.VariablesToTransfer.Count(), "bad number added"); }
public void CombinedGeneratedDifferentInitializationStatements() { var q1 = new GeneratedCode(); var q2 = new GeneratedCode(); var s1 = new Statements.StatementSimpleStatement("dude1"); var s2 = new Statements.StatementSimpleStatement("dude2"); q1.AddInitalizationStatement(s1); q2.AddInitalizationStatement(s2); var target = new CombinedGeneratedCode(); target.AddGeneratedCode(q1); target.AddGeneratedCode(q2); var initStatements = target.InitalizationStatements.ToArray(); Assert.AreEqual(2, initStatements.Length); }
public void TestSimpleCombine() { var q1 = new GeneratedCode(); var q2 = new GeneratedCode(); var s1 = new Statements.StatementSimpleStatement("dude1"); var s2 = new Statements.StatementSimpleStatement("dude2"); q1.Add(s1); q2.Add(s2); var v1 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int)); var v2 = DeclarableParameter.CreateDeclarableParameterExpression(typeof(int)); q1.SetResult(v1); q2.SetResult(v2); var target = new CombinedGeneratedCode(); target.AddGeneratedCode(q1); target.AddGeneratedCode(q2); Assert.AreEqual(1, target.QueryCode().Count(), "didn't combine blocks correctly"); var c = target.QueryCode().First(); Assert.AreEqual(2, c.Statements.Count(), "bad # of statements in combined query"); var st1 = c.Statements.First(); var st2 = c.Statements.Skip(1).First(); Assert.IsInstanceOfType(st1, typeof(Statements.StatementSimpleStatement), "st1"); Assert.IsInstanceOfType(st2, typeof(Statements.StatementSimpleStatement), "st2"); var sst1 = st1 as Statements.StatementSimpleStatement; var sst2 = st2 as Statements.StatementSimpleStatement; Assert.IsTrue("dude1" == sst1.Line || "dude1" == sst2.Line, "sst1"); Assert.IsTrue("dude2" == sst1.Line || "dude2" == sst2.Line, "sst2"); }
internal CombinedGeneratedCode Constructor() { CombinedGeneratedCode target = new CombinedGeneratedCode(); return target; // TODO: add assertions to method CombinedGeneratedCodeTest.Constructor() }
public void CombinedGeneratedDifferentInitalizationStatements() { var q1 = new GeneratedCode(); var q2 = new GeneratedCode(); var s1 = new Statements.StatementSimpleStatement("dude1"); var s2 = new Statements.StatementSimpleStatement("dude2"); q1.AddInitalizationStatement(s1); q2.AddInitalizationStatement(s2); var target = new CombinedGeneratedCode(); target.AddGeneratedCode(q1); target.AddGeneratedCode(q2); var initStatements = target.InitalizationStatements.ToArray(); Assert.AreEqual(2, initStatements.Length); }