
Hello, I recently worked with QuickCheck for a while, But I still can't handle it well, And a few questions come to my mind. 1. How to find properties In QuickCheck examples on the codes or the papers, they find good properties easily. How did they find these properties? What property can make us believed its implementation is collect? 2. Property driven developments But finally, I could find some patterns of the properties. For example, occasionally, their shape is like unF . f == id or unF . f == Just I thought it could be applied to writing parser, and lead me to "Property Driven Developments." I tried writing S-expression parser in this way. First, I defined my property as parseSexpr . prettySexpr == Just where parseSexpr :: String -> Maybe Sexpr, prettySexpr :: Sexpr -> String. As you see, I should write printer before parser. Fortunately writing such printer for S-expr is easy, but I don't know if what I did is right. Do you think I wasted times? Have you ever tried PDD? And has it worked? If you have experience with TDD, how do you think about PDD? If you have any answers in any questions above, please tell me them. Thanks in advance. Cheers -nwn

On Sun, Sep 27, 2009 at 3:19 PM, Yusaku Hashimoto
Do you think I wasted times? Have you ever tried PDD? And has it worked? If you have experience with TDD, how do you think about PDD?
If you have any answers in any questions above, please tell me them. Thanks in advance.
Cheers -nwn
Here are some links from my Wikipedia article on QC which tout it: - http://haskell.org/haskellwiki/QuickCheck_as_a_test_set_generator - http://blog.moertel.com/articles/2006/10/31/introductory-haskell-solving-the... - http://blog.moertel.com/pages/seven-lessons-from-the-icfp-programming-contes... - http://neilmitchell.blogspot.com/2006/11/systemfilepath-automated-testing.ht... - http://book.realworldhaskell.org/read/testing-and-quality-assurance.html -- gwern

On Mon, Sep 28, 2009 at 4:42 AM, Gwern Branwen
On Sun, Sep 27, 2009 at 3:19 PM, Yusaku Hashimoto
wrote: ... Do you think I wasted times? Have you ever tried PDD? And has it worked? If you have experience with TDD, how do you think about PDD?
If you have any answers in any questions above, please tell me them. Thanks in advance.
Cheers -nwn
Here are some links from my Wikipedia article on QC which tout it:
Thanks for pointers. But I feel curious about in many QC examples (especially RWH's in your pointers), if property is falsifiable, they changes definition of the property, not implementation. And it annoys me because it seemed to almost duplicate its implementation. Am I misunderstanding? Cheers -nwn

After a few more investigations, I can say QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases But QuickCheck does *not*: - help us to find good properties So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes. Cheers -nwn

On Mon, Sep 28, 2009 at 10:59 AM, Yusaku Hashimoto
After a few more investigations, I can say
QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases
But QuickCheck does *not*: - help us to find good properties
So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes.
Cheers -nwn
I don't think there's any automated way to come up with good properties given a function; that seems tantamount to solving AI. One thing I've meant to do is look at checkers: http://hackage.haskell.org/package/checkers - which I understand includes a collection of lots of properties for various datatypes and classes. Presumably you could look through it for ideas ('ooh, I forgot that my results should monotonically increase!') or pick the module closest to what you're testing and steal as many of its properties as you can. -- gwern

Not sure this is what you want, but I thought I'd mention "Formal Specifications for Free": http://www.erlang.org/euc/08/1005Hughes2.pdf (I wasn't able to find a better link. That talk is for Erlang, but people are working on this for Haskell QuickCheck.) / Emil Yusaku Hashimoto skrev:
After a few more investigations, I can say
QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases
But QuickCheck does *not*: - help us to find good properties
So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes.
Cheers -nwn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Fantastic.
If I understand correctly it inductively derives equations that hold
for a set of examples.
I am looking forward to see it in Haskell, who is working on the port?
titto
2009/9/28 Emil Axelsson
Not sure this is what you want, but I thought I'd mention "Formal Specifications for Free":
http://www.erlang.org/euc/08/1005Hughes2.pdf
(I wasn't able to find a better link. That talk is for Erlang, but people are working on this for Haskell QuickCheck.)
/ Emil
Yusaku Hashimoto skrev:
After a few more investigations, I can say
QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases
But QuickCheck does *not*: - help us to find good properties
So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes.
Cheers -nwn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/

Pasqualino "Titto" Assini skrev:
Fantastic.
If I understand correctly it inductively derives equations that hold for a set of examples.
AFAIU, it enumerates a set of terms and uses random testing to approximate an equivalence relation for these. The real trick, apparently, is in filtering out the interesting equations.
I am looking forward to see it in Haskell, who is working on the port?
John Hughes, Koen Claessen and Nick Smallbone. (At least.) / Emil

On Mon, 2009-09-28 at 23:59 +0900, Yusaku Hashimoto wrote:
After a few more investigations, I can say
QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases
But QuickCheck does *not*: - help us to find good properties
So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties.
This requires thought and practise. The properties are a partial formal description of what your program does. You have to decide what your program is supposed to do. There is no magic here. Sometimes you find that you adjust your properties to fit the program and sometimes adjust the program to fit the properties. To gain experience in thinking about properties of programs you probably want to look at books and articles and try examples. This is the kind of thing they teach in CS degrees. It is a matter of training yourself. Duncan

Yusaku Hashimoto wrote:
So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes.
Dijkstra would have said a good program (or program fragment, such as a library or even a single function) should /start out/ with properties, ideally a set of properties which completely specifies the program's output/behaviour. The implementation should then be structured in a way that makes it possible to prove (with reasonable effort) that the properties hold (and runnign QC on these properties then merely tests whether your proof was erroneous). Thus your problem is solved by construction. However, in practice we most often start out with only a vague idea of what our program should do. After hacking away for a time, however, we usually arrive at a level of granularity (individual small functions) where we have a more or less precise idea what we want it to achieve. It is then a matter of making this specification as precise as possible. If it turns out that a precise spec is unwieldy (too complex) then this is a hint that maybe it is not a good abstraction. Try to generalize or otherwise simplify the spec (refactoring the program) until you arrive at something manageable. It should then be possible to formalize this specification and convert it into a QC property. I think that this process is not something that can be automated (in general). Cheers Ben

Ben Franksen wrote:
If it turns out that a precise spec is unwieldy (too complex) then this is a hint that maybe it is not a good abstraction.
Or your specification language is insufficient to describe it... (I don't know about anybody else, but I find that when I use QC, about 75% of the bugs reported are bugs in the spec, and only 25% are bugs in the thing I'm actually trying to test...)

On Mon, Sep 28, 2009 at 3:28 PM, Andrew Coppin
Ben Franksen wrote:
If it turns out that a precise spec is unwieldy (too complex) then this is a hint that maybe it is not a good abstraction.
Or your specification language is insufficient to describe it...
(I don't know about anybody else, but I find that when I use QC, about 75% of the bugs reported are bugs in the spec, and only 25% are bugs in the thing I'm actually trying to test...)
Maybe that means that you don't apply the same level of care to testing as you do to coding your main program. Or perhaps that is the quality of many bugs: the code does exactly what I intended, but what I intended was wrong. Luke
participants (8)
-
Andrew Coppin
-
Ben Franksen
-
Duncan Coutts
-
Emil Axelsson
-
Gwern Branwen
-
Luke Palmer
-
Pasqualino "Titto" Assini
-
Yusaku Hashimoto