suite : Test
suite =
describe "Add"
[ test "one plus two is three" <|
\_ ->
let
expected =
3
actual =
add 1 2
in
Expect.equal expected actual
]
suite : Test
suite =
describe "The List module"
[ describe "List.reverse"
[ fuzz (list string) "length of list doesn't change" <|
\strList ->
let
originalLength =
List.length strList
in
strList
|> List.reverse
|> List.length
|> Expect.equal originalLength
]
]
When a list is reversed, the length should not change
Property based testing relies on properties.
When given any randomly generated value, the property will always be true.
AKA test check useful characteristics that must be seen in the output
A human is deciding the input and output of example tests.
Decreasing human involvement results is less developer bias.
Which leads to more bugs being caught early on.
What kind of input is supported?
How can the input be generated?
What statements can we make about the output?
[2, 3, 1]
[3, 4, 2]
[2, 3, 4]
[1, 2, 3]
sort
sort
+1
+1
[3, 4, 2]
[4, 3, 2]
reverse
reverse
[3, 4, 2]
[2, 3, 4]
sort
.length
.length
[1, 2, 2, 1]
[1, 2]
unique
[1, 2]
unique
[1, 2]
unique
[3, 1, 2]
sort
implies pairwise order
[1, 2, 3]
(1 <= 2) (2 <= 3)