www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13014] New: Test Phobos with a QuickCheck-like tool too?

https://issues.dlang.org/show_bug.cgi?id=13014

          Issue ID: 13014
           Summary: Test Phobos with a QuickCheck-like tool too?
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

QuickCheck is a testing tool widely used in Haskell:

http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck1
http://en.wikipedia.org/wiki/QuickCheck

In QuickCheck the programmer writes assertions about logical properties that a
function should fulfill. Then QuickCheck attempts to generate test cases that
falsify these assertions.<
The test cases are generated randomly, up to a certain length and complexity, that can be specified. In Haskell there is also a similar tool, SmallCheck, that "allows to verify properties for all test cases up to some depth", so its test cases are not random, it's deterministic: http://ro-che.info/articles/2013-02-19-smallcheck.html https://github.com/feuerbach/smallcheck There are QuickCheck-like tools for most languages, including D and C++: https://github.com/mcandre/dashcheck http://software.legiasoft.com/quickcheck/ In this enhancement request I suggest to consider using a QuickCheck-like tool (like DashCheck) to test Phobos, and to better remove Phobos bugs. The functions that specify the logical proprieties of the Phobos code should be bundled inside the standard D distributions, like the unittests. One side effect of shipping the D compiler with a QuickCheck-like tool (used for Phobos, and later for the front-end written in D) is to encourage D programmers to use such standard tool in their programs. I think this could improve the quality of all D code, beyond Phobos. Note: such testing functions are similar to the post-conditions. So in theory a well implemented QuickCheck-like tool for D should use the post-conditions to generate the test cases. --
Jul 01 2014