[llvm-commits] [llvm] r48880 - /llvm/branches/ggreif/use-diet/include/llvm/User.h

Gabor Greif ggreif at gmail.com
Thu Mar 27 08:18:39 PDT 2008


Author: ggreif
Date: Thu Mar 27 10:18:33 2008
New Revision: 48880

URL: http://llvm.org/viewvc/llvm-project?rev=48880&view=rev
Log:
add usecase testing using QuickCheck

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/User.h

Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=48880&r1=48879&r2=48880&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Thu Mar 27 10:18:33 2008
@@ -111,6 +111,7 @@
 
 The following literate Haskell fragment demonstrates the concept:
 
+> import Test.QuickCheck
 > 
 > digits :: Int -> [Char] -> [Char]
 > digits 0 acc = '0' : acc
@@ -146,6 +147,30 @@
 
 Now, as expected, printing <pref test> gives 40.
 
+We can quickCheck this with following property:
+
+> testcase = dist 2000 []
+> testcaseLength = length testcase
+> 
+> identityProp n = n > 0 && n <= testcaseLength ==> length arr == pref arr
+>     where arr = takeLast n testcase
+
+As expected <quickCheck identityProp> gives:
+
+*Main> quickCheck identityProp
+OK, passed 100 tests.
+
+Let's be a bit more exhaustive:
+
+> 
+> deepCheck p = check (defaultConfig { configMaxTest = 500 }) p
+> 
+
+And here is the result of <deepCheck identityProp>:
+
+*Main> deepCheck identityProp
+OK, passed 500 tests.
+
 
 To maintain the invariant that the 2 LSBits of each Value* in Use
 never change after being set up, setters of Use::Val must re-tag the





More information about the llvm-commits mailing list