Skip to content

Latest commit

 

History

History
134 lines (114 loc) · 2.52 KB

ch14.adoc

File metadata and controls

134 lines (114 loc) · 2.52 KB

14 Testing

14.3 Conventional testing

link:addition/Addition.hs[role=include]

14.5 Morse code

link:morsecode/test/Spec.hs[role=include]

I have morsecode instead of morse and loadding tests is stack ghci morsecode:morsecode-test

14.7 Chapter Exercises

Validating numbers into words

link:wordnumber/test/Spec.hs[role=include]

Using QuickCheck

Caution
had to use Test.QuickCheck.Function in point 8 to make it work

Run tests: stack test

  1. propHalf +++ OK, passed 100 tests.

  2. propSort +++ OK, passed 100 tests.

  3. plusAssociative +++ OK, passed 100 tests.

    plusCommutative +++ OK, passed 100 tests.

  4. multiAssociative +++ OK, passed 100 tests.

    multiCommutative +++ OK, passed 100 tests.

  5. propQuotRem +++ OK, passed 100 tests.

    propDivMod +++ OK, passed 100 tests.

  6. powerAssociative

    *** Failed! Falsifiable (after 1 test):
    0
    0
    0

    powerCommutative

    *** Failed! Falsifiable (after 2 tests):
    1
    0
  7. propReverse +++ OK, passed 100 tests.

  8. applyProp +++ OK, passed 100 tests.

    composeProp +++ OK, passed 100 tests.

  9. inConcatProp

    *** Failed! Falsifiable (after 2 tests and 2 shrinks):
    "a"
    "b"

    concatProp +++ OK, passed 100 tests.

  10. lenTakeProb

    *** Failed! Falsifiable (after 3 tests and 1 shrink):
    2
    ""
  11. idProp +++ OK, passed 100 tests.

link:usingquickcheck/test/Spec.hs[role=include]

Failure

Floating point precission cannot guarantee equality

link:ch14_14.7_failure.hs[role=include]
*Main> main
*** Failed! Falsifiable (after 2 tests and 1037 shrinks):
2.225078033262077e-308

Idempotence

link:ch14_14.7_indepotence.hs[role=include]
+++ OK, passed 100 tests.
+++ OK, passed 100 tests.

Make a Gen random generator for the datatype

link:ch14_14.7_1.hs[role=include]

Hangman testing

Warning
not done, will have to come back to this later
link:ch14_14.7_hangman.hs[role=include]

Validating ciphers

Warning
need to do proper generators
link:ch14_14.7_2.hs[role=include]