developers.de
daenet's .NET Community

Tracing PEX condition paths

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

If you want to now how exactly PEX is solving conditions (dynamic symbol execution) in different braches of your code, then you should take a look on following example. The method SomeMethod has differnet branches. For each branch there is one condition, which internally locks slightly different.

[PexMethod]
public int SomeMethod(int x, int y)
{
            if (x + y == 7)
            {
                PexStore.Value<string>("Condition", PexSymbolicValue.GetPathConditionString());
                PexStore.Value<string>("Raw Condition",
PexSymbolicValue.GetRawPathConditionString());
                return 1;
            }
            else if (x == 4)
            {
                PexStore.Value<string>("Condition",
PexSymbolicValue.GetPathConditionString());
                PexStore.Value<string>("Raw Condition",
PexSymbolicValue.GetRawPathConditionString());
                return 2;
            }
            else if (y == 3)
            {
                PexStore.Value<string>("Condition",
PexSymbolicValue.GetPathConditionString());
                PexStore.Value<string>("Raw Condition",
PexSymbolicValue.GetRawPathConditionString());
                return 3;
            }
            else if (y == 5)
            {
                PexStore.Value<string>("Condition",
PexSymbolicValue.GetPathConditionString());
                PexStore.Value<string>("Raw Condition",
PexSymbolicValue.GetRawPathConditionString());
                return 3;
            }
            else
            {
                PexStore.Value<string>("Condition",
PexSymbolicValue.GetPathConditionString());
                PexStore.Value<string>("Raw Condition",
PexSymbolicValue.GetRawPathConditionString());
                return 4;
            }
        }

 

When you explore this method with PEX following result appears:


image

Note that statements PexAssume and PexStore are added by me to explore condition paths. They are not consistent part of the program.


Posted Apr 13 2009, 09:03 PM by Damir Dobric

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH