D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13014 - Test Phobos with a QuickCheck-like tool too?
Summary: Test Phobos with a QuickCheck-like tool too?
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: tools (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-02 00:22 UTC by Brad Roberts
Modified: 2022-12-17 10:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2014-07-02 00:22:17 UTC
(Originally posted by 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.