Re: linq - how to test expression reducers
"Chad Lee" <[email protected]> Fri, 15 Aug 2008 09:20:03 -0500
| Newsgroups | gmane.comp.windows.dotnet.nhibernate.devel |
|---|---|
| Message-ID | <[email protected]> |
I just ran this simple test: var expr1 = Expression.And( Expression.Constant(true), Expression.Constant(false)); var expr2 = Expression.And( Expression.Constant(true), Expression.Constant(false)); Assert.Equal(expr1, expr2); which fails.... That just seems stupid to me. On Fri, Aug 15, 2008 at 9:08 AM, Ayende Rahien <[email protected]> wrote: > What about something like: > var reducedExpression = Reduce( () => true && x>1 && x<2)); > AssertExpressionEq( reducedExpression, > new BinaryExpression{ And, new (x>1), new (x<2)); > > On Fri, Aug 15, 2008 at 4:54 PM, Tuna Toksöz <[email protected]> wrote: > >> Hello team, >> I am working on Expression reducers to simplify complex expressions. >> I made LogicalExpressionReducer which simply converts not(not(not(true))) >> to ConstantExpression(false) and (true & x.Name=="johndoe") to >> (x.Name=="john doe"), meaning that it just uses the truth table to reduce >> expressions. >> >> The problem with expressions is that they are trees! For simple ones, it >> is easy to check if I get the same result but complex ones are hard to deal >> with. >> I first thought that I can use .ToString() of expression which produces >> string representation of an expression, that is some thing like >> Assert.AreEqual("false",reducedExpression.ToString()) >> >> But this simply sounds incorrect to me. I then thought about using >> visitors to check for equality, but not sure about that. >> >> 2nd one sounds the way to go, but are there any simpler way to test it? >> >> Producing >> >> -- >> Tuna Toksöz >> >> Typos included to enhance the readers attention! >> >> ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win great >> prizes >> Grand prize is a trip for two to an Open Source event anywhere in the >> world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Nhibernate-development mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/nhibernate-development >> >> > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Nhibernate-development mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/nhibernate-development > > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Nhibernate-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nhibernate-development