-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathWordsTest.elm
More file actions
41 lines (34 loc) · 1.12 KB
/
WordsTest.elm
File metadata and controls
41 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
module WordsTest exposing (allTests)
import Expect
import Fuzz exposing (Fuzzer, list, string)
import List exposing (foldl)
import String.Extra exposing (isBlank)
import Test exposing (Test, fuzz)
fuzzMultilineText : Fuzzer String
fuzzMultilineText =
let
-- Is there a system-independent value for newline?
newlineCharacter =
"\n"
appendLine text followingLine =
text ++ followingLine ++ newlineCharacter
in
list string
|> Fuzz.map (foldl appendLine "")
allTests : Test
allTests =
fuzz fuzzMultilineText "match String.words when not blank; return [] otherwise" <|
\text ->
let
-- I don't know how to write a fuzzer that generates
-- only non-blank collections of lines, so I combined the two tests,
-- which I otherwise dislike doing.
expected =
if isBlank text then
[]
else
String.words text
in
Expect.equal
expected
(String.Extra.words text)