

Microsoft Code Digger - scottcha
http://channel9.msdn.com/coding4fun/blog/Digging-into-your-code-with-the-free-Microsoft-Code-Digger-and-the-power-of-Pex

======
testbro
A similar tool exists for Java, although it doesn't rely on symbolic execution
(but IIRC it is able to use it for integer constraints) but evolutionary test
data generation [1]. There's a plugin for Eclipse too.

[1] : <http://www.evosuite.org>

------
Aurel1us
Anyone know something similar for C/C++ or Python ?

~~~
monksy
Or for Java.

~~~
grdvnl
Pex is based on the Daikon dynamic invariant. This document explains some
results and examples in certain languages.

[http://groups.csail.mit.edu/pag/daikon/download/doc/daikon.p...](http://groups.csail.mit.edu/pag/daikon/download/doc/daikon.pdf)

~~~
rainforest
Is it? I was under the impression it just uses symbolic execution rather than
invariant detection.

~~~
grdvnl
Your are right. I mixed up dynamic symbolic execution with invariant
detection. I know there is something called DySy which does do invariant
detection using dynamic symbolic execution.

------
earlz
I tried it. Doesn't usually work all that well though, and basically only
works on built in .Net types. If you pass in your own object containing only
.Net types, it's not smart enough to fill those in with potential test data.
Interesting idea, but I found it completely worthless

~~~
romaniv
It would be very, very useful if only it worked with regular expressions. Or
if you could run it against F# functions.

~~~
danbruc
I just tested it using Pex for fun and - to my surprise - Pex was able to deal
with regular expression and this AFAIK without any build-in knowledge of
regular expressions.

    
    
      using System;
      using System.Text.RegularExpressions;
    
      public class Program
      {
        public static String Puzzle(String input)
        {
          if (new Regex("123(foo|bar){3}456[0-9]{5}789").IsMatch(input))
          {
            throw new ArgumentException();
          }
          else
          {
            return input;
          }
        }
      }
    

Pex reported three test cases.

    
    
      null                         ArgumentNullException
      ""                           okay
      "123foobarbar45600000789bb"  ArgumentException
    

Try this example yourself.

[http://www.pexforfun.com/default.aspx?language=CSharp&co...](http://www.pexforfun.com/default.aspx?language=CSharp&code=HgHsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee__997o7nU4n99%2f%2fP1xmZAFs9s5K2smeIYCqyB8%2ffnwfPyLWTbG8SF9fN22_OEz8v8Zv8nft_FV_sS6z_vTdqs6bpqiWzWGSrNaTspim0zJrmvRlXV3U2SL5xUma6hdNm7X043VbA9zL9Q9_UOZb_lexXK3bO9QW7dO0OE_3lvlVSv3k77Y_2t27t3VeVT8zyeo7v%2fjeL9m%2f%2f_n3drYffv8X3%2f8lDw4efnRnfNZ8kbXT_ZZAucMgBFCatvO6ukoB7Li_WC%2fyZXv6bpqvWkJ6684hN%2fol%2fG9eNnnwZp2363opqLmGvyT5Jf9PAAAA%2f%2f8%3d)

UPDATE: I was wrong - Rex was integrated into Pex in 2010 and this made Pex
much smarter when it has to deal with regular expressions.

------
nickbarnwell
I'll prefix my question by saying I'm unfamiliar with QC beyond knowing of its
existence and roughly what it does in terms of generating test values:

Am I misunderstanding, or is this akin to QuickCheck for C#?

~~~
danbruc
The QuickCheck manual states that they are randomly generating test cases [1].
This tool is build on top of Pex [2] which analyzes the byte code and uses the
Z3 theorem prover [3] to systematically find inputs covering all code paths.
This is really a impressive and powerful tool. You can have some fun with it
at the Pex for fun site [4]. There is some secret code and you have to
reimplement that code based on the test results generated by Pex comparing
your implementation to the secret implementation.

[1] <http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html> [2]
<http://research.microsoft.com/en-us/projects/pex/> [3]
<http://research.microsoft.com/en-us/projects/z3m/> [4]
<http://www.pexforfun.com/>

~~~
0x0
The pexforfun thing seemed pretty clever:

    
    
      // What values of v and i can cause an exception? Ask Pex to find out!
      public static void Puzzle(int[] v, int i)
      {
        if (v[i + 2] + 5 == v.Length + i)
          throw new Exception("hidden bug!"); 
      }
    

and then it automatically finds the breaking input:

    
    
      {-6} 	 -2 	 Exception 	 hidden bug!

------
suyash
Anything similar for JavaScript?

------
Yuioup
I've noticed here and on reddit that Microsoft stories don't get much
attention. Rightly so?

