/// <summary>Test stub for TranslateGeneratedCode(GeneratedCode)</summary> public Dictionary <string, object> TranslateGeneratedCode(CPPTranslator target, IExecutableCode code) { MEFUtilities.Compose(target); Dictionary <string, object> result = target.TranslateGeneratedCode(code); return(result); }
public void TestInit() { TestUtils.ResetLINQLibrary(); var t = new TypeHandlerCache(); MEFUtilities.Compose(t); }
/// <summary> /// Returns a save manager ready to go. /// </summary> /// <returns></returns> private static VariableSaverManager GetInitializedSaveManager() { var mgr = new VariableSaverManager(); MEFUtilities.Compose(mgr); return(mgr); }
public void TestSimpleAddition() { MEFUtilities.Compose(new TypeHandlers.TypeHandlerCache()); AggregateFromSeedResultOperator agg = new AggregateFromSeedResultOperator(Expression.Constant(1), Expression.Lambda(Expression.MakeBinary(ExpressionType.Add, Expression.Parameter(typeof(int), "count"), Expression.Constant(1)), Expression.Parameter(typeof(int), "count")), null); ROAggregate processor = new ROAggregate(); GeneratedCode gc = new GeneratedCode(); var result = ProcessResultOperator(processor, agg, null, gc); Assert.AreEqual(typeof(int), result.Type, "Expected the type to be an integer!"); Assert.IsInstanceOfType(result, typeof(DeclarableParameter), "Expected a var simple!"); var vs = result as DeclarableParameter; Assert.AreEqual("1", vs.InitialValue.RawValue, "Incorrect seed value"); /// /// Now make sure the statements came back ok! /// gc.DumpCodeToConsole(); Assert.AreEqual(0, gc.CodeBody.DeclaredVariables.Count(), "Expected no bookings"); Assert.AreEqual(1, gc.CodeBody.Statements.Count(), "expected a statement!"); Assert.IsInstanceOfType(gc.CodeBody.Statements.First(), typeof(Statements.StatementAggregate), "expected an assignment statement!"); var ass = gc.CodeBody.Statements.First() as Statements.StatementAggregate; StringBuilder bld = new StringBuilder(); bld.AppendFormat("{0}+1", ass.ResultVariable.ParameterName); Assert.AreEqual(bld.ToString(), ass.Expression.RawValue, "the raw value of hte expression is not right"); }
public CPPTranslator Constructor() { CPPTranslator target = new CPPTranslator(); MEFUtilities.Compose(target); return(target); // TODO: add assertions to method CPPTranslatorTest.Constructor() }
public void TestBasicTakeSkip() { var t = new TypeHandlerCache(); MEFUtilities.Compose(t); GeneratedCode gc = new GeneratedCode(); gc.Add(new LINQToTTreeLib.Statements.StatementInlineBlock()); gc.Add(new LINQToTTreeLib.Tests.TestUtils.SimpleLoop()); var skipper = new SkipResultOperator(Expression.Constant(10)); ProcessResultOperator(new ROTakeSkipOperators(), skipper, null, gc); }
internal void TestLookupTwice(int tindex) { var t = GenerateAType(tindex); MEFUtilities.AddPart(new DummyRO()); var target = new QVResultOperators(); MEFUtilities.Compose(target); var result1 = target.FindScalarROProcessor(t); var result2 = target.FindScalarROProcessor(t); Assert.AreEqual(result1, result2, "Expected the same result when called with the same inputs!"); }
public void TestForTooManyCodeBlocks() { CPPTranslator target = new CPPTranslator(); MEFUtilities.Compose(target); var toomany = new TooManyStatemnets(); var result = target.TranslateGeneratedCode(toomany); Assert.IsTrue(((int)result["NumberOfQueryFunctions"]) > 1, string.Format("Number of queries was not larger than 1, it was {0}", result["NumberOfQueryFunctions"])); var codeBlocks = result["QueryFunctionBlocks"] as IEnumerable <IEnumerable <string> >; Assert.AreEqual(result["NumberOfQueryFunctions"], codeBlocks.Count(), "Non-matching number of code blocks"); }
public void TestMethodCall() { var looker = new BogusTT(); var target = new TypeHandlerCache(); MEFUtilities.AddPart(looker); MEFUtilities.Compose(target); var m = typeof(int).GetMethods().Where(me => me.Name == "ToString").First(); var expr = Expression.Call(Expression.Constant(10), m); GeneratedCode gc = new GeneratedCode(); var result = CodeMethodCall(target, expr, gc); Assert.AreEqual(result.Type, typeof(int), "result type"); }
public void ProcessConstantRefROOT() { var looker = new BogusTT(); var target = new TypeHandlerCache(); MEFUtilities.AddPart(looker); MEFUtilities.Compose(target); ConstantExpression expr = Expression.Constant(new ROOTNET.NTH1F("hi", "there", 10, 0.0, 10.0)); GeneratedCode gc = new GeneratedCode(); var v = ProcessConstantReference(target, expr, gc); Assert.AreEqual("dude", v.RawValue); Assert.AreEqual(typeof(ROOTNET.NTH1F), v.Type); }
private static IValue RunArrayLengthOnExpression(Expression arrayLenLambda, Type expectedType) { MEFUtilities.AddPart(new QVResultOperators()); MEFUtilities.AddPart(new ROCount()); MEFUtilities.AddPart(new TypeHandlerCache()); MEFUtilities.AddPart(new TypeHandlerTranslationClass()); GeneratedCode gc = new GeneratedCode(); CodeContext cc = new CodeContext(); MEFUtilities.Compose(new QueryVisitor(gc, cc, MEFUtilities.MEFContainer)); var result = ExpressionToCPP.GetExpression(arrayLenLambda, gc, cc, MEFUtilities.MEFContainer); Assert.IsNotNull(result, "result"); Assert.AreEqual(expectedType, result.Type, "result type"); return(result); }
internal void TestLookup(int tindex) { var t = GenerateAType(tindex); var dummy = new DummyRO(); MEFUtilities.AddPart(dummy); var target = new QVResultOperators(); MEFUtilities.Compose(target); var result = target.FindScalarROProcessor(t); if (t == typeof(DummyRO)) { Assert.AreEqual(dummy, result, "expected to get back the right object"); } else { Assert.IsNull(result, "Expected no found guy to come back!"); } }
public void Setup() { TestUtils.ResetLINQLibrary(); MEFUtilities.AddPart(new QVResultOperators()); MEFUtilities.Compose(new TypeHandlerCache()); }