public void CacheObjectWhenCPPChanges() { TestUtils.ResetLINQLibrary(); // Make sure that when the C++ code changes, the cache key for lookup of results will also change. var q = new QueriableDummy <ntup>(); var i = q.Select(e => DoItClass.DoIt(e.run)).Where(x => x > 2).Count(); var query = DummyQueryExectuor.LastQueryModel; // Look for a hash value. var str1 = FormattingQueryVisitor.Format(query); Console.WriteLine(str1); var m = Regex.Match(str1, @"DoIt([^\(]+)"); Assert.IsTrue(m.Success); }
public void TestDualFirstWithCPPCode() { // This test produces something caught in the wild (caused a compile error). // The bug has to do with a combination of the First predicate and the CPPCode statement conspiring // to cause the problem, unfortunately. So, the test is here. var q = new QueriableDummy <ntup3>(); var resultA = from evt in q select new { r1 = evt.run1.Where(r => r > 3).Select(r => DoItClass.DoIt(r)), r2 = evt.run2.Where(r => r > 4).Select(r => DoItClass.DoIt(r)) }; var resultB = from e in resultA select new { joinedR = from r1 in e.r1 select(from r2 in e.r2 orderby r1 - r2 ascending select r2).First() }; var result = from e in resultB from r in e.joinedR select r; var c = result.Sum(); Assert.IsNotNull(DummyQueryExectuor.FinalResult, "Expecting some code to have been generated!"); var query = DummyQueryExectuor.FinalResult; query.DumpCodeToConsole(); Assert.AreEqual(2, query.CodeBody.Statements.Count(), "# of statements in the code body"); var lm = query.DumpCode().Where(l => l.Contains(" = ((*(*this).run2).at(aInt32_16))*2;")).FirstOrDefault(); Assert.IsNotNull(lm, "Unable to find proper addition line"); }