Skip all but first test of each example

This allows learners to gradually approach exercise. However, unlike
commented tests, the Elm compiler is still able to infer type
information from the skipped tests.
This commit is contained in:
Jay Hayes 2017-07-05 15:35:15 -05:00
parent d76d7ecb7b
commit 4d81104a85
31 changed files with 1250 additions and 932 deletions

View file

@ -16,14 +16,17 @@ tests =
describe "Accumulate" describe "Accumulate"
[ test "[] Accumulate" <| [ test "[] Accumulate" <|
\() -> Expect.equal [] (accumulate square []) \() -> Expect.equal [] (accumulate square [])
, test "square Accumulate" <| , skip <|
\() -> Expect.equal [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ]) test "square Accumulate" <|
, test "toUpper Accumulate" <| \() -> Expect.equal [ 1, 4, 9 ] (accumulate square [ 1, 2, 3 ])
\() -> , skip <|
Expect.equal [ "HELLO", "WORLD" ] test "toUpper Accumulate" <|
(accumulate String.toUpper [ "hello", "world" ]) \() ->
, test "reverse Accumulate" <| Expect.equal [ "HELLO", "WORLD" ]
\() -> (accumulate String.toUpper [ "hello", "world" ])
Expect.equal [ "olleh", "dlrow" ] , skip <|
(accumulate String.reverse [ "hello", "world" ]) test "reverse Accumulate" <|
\() ->
Expect.equal [ "olleh", "dlrow" ]
(accumulate String.reverse [ "hello", "world" ])
] ]

View file

@ -13,36 +13,47 @@ tests =
[ describe "no allergies means not allergic" [ describe "no allergies means not allergic"
[ test "peanuts" <| [ test "peanuts" <|
\() -> Expect.equal False (isAllergicTo "peanuts" 0) \() -> Expect.equal False (isAllergicTo "peanuts" 0)
, test "cats" <| , skip <|
\() -> Expect.equal False (isAllergicTo "cats" 0) test "cats" <|
, test "strawberries" <| \() -> Expect.equal False (isAllergicTo "cats" 0)
\() -> Expect.equal False (isAllergicTo "strawberries" 0) , skip <|
test "strawberries" <|
\() -> Expect.equal False (isAllergicTo "strawberries" 0)
] ]
, test "is allergic to eggs" <| , skip <|
\() -> Expect.equal True (isAllergicTo "eggs" 1) test "is allergic to eggs" <|
\() -> Expect.equal True (isAllergicTo "eggs" 1)
, describe "has the right allergies" , describe "has the right allergies"
[ test "eggs" <| [ skip <|
\() -> Expect.equal True (isAllergicTo "eggs" 5) test "eggs" <|
, test "shellfish" <| \() -> Expect.equal True (isAllergicTo "eggs" 5)
\() -> Expect.equal True (isAllergicTo "shellfish" 5) , skip <|
, test "strawberries" <| test "shellfish" <|
\() -> Expect.equal False (isAllergicTo "strawberries" 5) \() -> Expect.equal True (isAllergicTo "shellfish" 5)
, skip <|
test "strawberries" <|
\() -> Expect.equal False (isAllergicTo "strawberries" 5)
] ]
] ]
, describe "toList" , describe "toList"
[ test "no allergies at all" <| [ skip <|
\() -> Expect.equal [] (toList (0)) test "no allergies at all" <|
, test "allergic to just peanuts" <| \() -> Expect.equal [] (toList (0))
\() -> Expect.equal [ "peanuts" ] (toList (2)) , skip <|
, test "allergic to everything" <| test "allergic to just peanuts" <|
\() -> \() -> Expect.equal [ "peanuts" ] (toList (2))
Expect.equal (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) , skip <|
(255 |> toList |> List.sort) test "allergic to everything" <|
, test "ignore non allergen score parts" <| \() ->
\() -> Expect.equal [ "eggs" ] (toList 257) Expect.equal (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
, test "ignore all non allergen score parts" <| (255 |> toList |> List.sort)
\() -> , skip <|
Expect.equal (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ]) test "ignore non allergen score parts" <|
(509 |> toList |> List.sort) \() -> Expect.equal [ "eggs" ] (toList 257)
, skip <|
test "ignore all non allergen score parts" <|
\() ->
Expect.equal (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
(509 |> toList |> List.sort)
] ]
] ]

View file

@ -12,80 +12,99 @@ tests =
\() -> \() ->
Expect.equal [] Expect.equal []
(detect "diaper" [ "hello", "world", "zombies", "pants" ]) (detect "diaper" [ "hello", "world", "zombies", "pants" ])
, test "detects simple anagram" <| , skip <|
\() -> test "detects simple anagram" <|
Expect.equal [ "tan" ] \() ->
(detect "ant" [ "tan", "stand", "at" ]) Expect.equal [ "tan" ]
, test "does not detect false positives" <| (detect "ant" [ "tan", "stand", "at" ])
\() -> , skip <|
Expect.equal [] test "does not detect false positives" <|
(detect "galea" [ "eagle" ]) \() ->
, test "detects multiple anagrams" <| Expect.equal []
\() -> (detect "galea" [ "eagle" ])
Expect.equal [ "stream", "maters" ] , skip <|
(detect "master" [ "stream", "pigeon", "maters" ]) test "detects multiple anagrams" <|
, test "does not detect anagram subsets" <| \() ->
\() -> Expect.equal [ "stream", "maters" ]
Expect.equal [] (detect "master" [ "stream", "pigeon", "maters" ])
(detect "good" [ "dog", "goody" ]) , skip <|
, test "detects anagram" <| test "does not detect anagram subsets" <|
\() -> \() ->
Expect.equal [ "inlets" ] Expect.equal []
(detect "listen" [ "enlists", "google", "inlets", "banana" ]) (detect "good" [ "dog", "goody" ])
, test "detects even more anagrams" <| , skip <|
\() -> test "detects anagram" <|
Expect.equal [ "gallery", "regally", "largely" ] \() ->
(detect "allergy" [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ]) Expect.equal [ "inlets" ]
, test "does not detect indentical words" <| (detect "listen" [ "enlists", "google", "inlets", "banana" ])
\() -> , skip <|
Expect.equal [ "cron" ] test "detects even more anagrams" <|
(detect "corn" [ "corn", "dark", "Corn", "rank", "CORN", "cron", "park" ]) \() ->
, test "does not detect non-anagrams with identical checksum" <| Expect.equal [ "gallery", "regally", "largely" ]
\() -> (detect "allergy" [ "gallery", "ballerina", "regally", "clergy", "largely", "leading" ])
Expect.equal [] , skip <|
(detect "mass" [ "last" ]) test "does not detect indentical words" <|
, test "detects anagrams case-insensitively" <| \() ->
\() -> Expect.equal [ "cron" ]
Expect.equal [ "Carthorse" ] (detect "corn" [ "corn", "dark", "Corn", "rank", "CORN", "cron", "park" ])
(detect "Orchestra" [ "cashregister", "Carthorse", "radishes" ]) , skip <|
, test "detects anagrams using case-insensitive subject" <| test "does not detect non-anagrams with identical checksum" <|
\() -> \() ->
Expect.equal [ "carthorse" ] Expect.equal []
(detect "Orchestra" [ "cashregister", "carthorse", "radishes" ]) (detect "mass" [ "last" ])
, test "detects anagrams using case-insensitve possible matches" <| , skip <|
\() -> test "detects anagrams case-insensitively" <|
Expect.equal [ "Carthorse" ] \() ->
(detect "orchestra" [ "cashregister", "Carthorse", "radishes" ]) Expect.equal [ "Carthorse" ]
, test "does not detect a word as its own anagram" <| (detect "Orchestra" [ "cashregister", "Carthorse", "radishes" ])
\() -> , skip <|
Expect.equal [] test "detects anagrams using case-insensitive subject" <|
(detect "banana" [ "Banana" ]) \() ->
, test "does not detect a anagram if the original word is repeated" <| Expect.equal [ "carthorse" ]
\() -> (detect "Orchestra" [ "cashregister", "carthorse", "radishes" ])
Expect.equal [] , skip <|
(detect "go" [ "go Go GO" ]) test "detects anagrams using case-insensitve possible matches" <|
, test "anagrams must use all letters exactly once (go)" <| \() ->
\() -> Expect.equal [ "Carthorse" ]
Expect.equal [] (detect "orchestra" [ "cashregister", "Carthorse", "radishes" ])
(detect "tapper" [ "patter" ]) , skip <|
, test "eliminates anagrams with the same checksum" <| test "does not detect a word as its own anagram" <|
\() -> \() ->
Expect.equal [] Expect.equal []
(detect "mass" [ "last" ]) (detect "banana" [ "Banana" ])
, test "detects unicode anagrams" <| , skip <|
\() -> test "does not detect a anagram if the original word is repeated" <|
Expect.equal [ "ΒΓΑ", "γβα" ] \() ->
(detect "ΑΒΓ" [ "ΒΓΑ", "ΒΓΔ", "γβα" ]) Expect.equal []
, test "eliminates misleading unicode anagrams" <| (detect "go" [ "go Go GO" ])
\() -> , skip <|
Expect.equal [] test "anagrams must use all letters exactly once (go)" <|
(detect "ΑΒΓ" [ "ABΓ" ]) \() ->
, test "capital word is not own anagram" <| Expect.equal []
\() -> (detect "tapper" [ "patter" ])
Expect.equal [] , skip <|
(detect "BANANA" [ "Banana" ]) test "eliminates anagrams with the same checksum" <|
, test "anagrams must use all letters exactly once (banana)" <| \() ->
\() -> Expect.equal []
Expect.equal [] (detect "mass" [ "last" ])
(detect "patter" [ "tapper" ]) , skip <|
test "detects unicode anagrams" <|
\() ->
Expect.equal [ "ΒΓΑ", "γβα" ]
(detect "ΑΒΓ" [ "ΒΓΑ", "ΒΓΔ", "γβα" ])
, skip <|
test "eliminates misleading unicode anagrams" <|
\() ->
Expect.equal []
(detect "ΑΒΓ" [ "ABΓ" ])
, skip <|
test "capital word is not own anagram" <|
\() ->
Expect.equal []
(detect "BANANA" [ "Banana" ])
, skip <|
test "anagrams must use all letters exactly once (banana)" <|
\() ->
Expect.equal []
(detect "patter" [ "tapper" ])
] ]

View file

@ -10,26 +10,35 @@ tests =
describe "AtbashCipher" describe "AtbashCipher"
[ test "encode no" <| [ test "encode no" <|
\() -> Expect.equal "ml" (encode "no") \() -> Expect.equal "ml" (encode "no")
, test "encode yes" <| , skip <|
\() -> Expect.equal "bvh" (encode "yes") test "encode yes" <|
, test "encode OMG" <| \() -> Expect.equal "bvh" (encode "yes")
\() -> Expect.equal "lnt" (encode "OMG") , skip <|
, test "encode O M G" <| test "encode OMG" <|
\() -> Expect.equal "lnt" (encode "O M G") \() -> Expect.equal "lnt" (encode "OMG")
, test "encode long word" <| , skip <|
\() -> Expect.equal "nrmwy oldrm tob" (encode "mindblowingly") test "encode O M G" <|
, test "encode numbers" <| \() -> Expect.equal "lnt" (encode "O M G")
\() -> Expect.equal "gvhgr mt123 gvhgr mt" (encode "Testing, 1 2 3, testing.") , skip <|
, test "encode sentence" <| test "encode long word" <|
\() -> Expect.equal "gifgs rhurx grlm" (encode "Truth is fiction.") \() -> Expect.equal "nrmwy oldrm tob" (encode "mindblowingly")
, test "encode all things" <| , skip <|
\() -> test "encode numbers" <|
Expect.equal "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt" \() -> Expect.equal "gvhgr mt123 gvhgr mt" (encode "Testing, 1 2 3, testing.")
(encode "The quick brown fox jumps over the lazy dog.") , skip <|
, test "decode word" <| test "encode sentence" <|
\() -> Expect.equal "exercism" (decode "vcvix rhn") \() -> Expect.equal "gifgs rhurx grlm" (encode "Truth is fiction.")
, test "decode sentence" <| , skip <|
\() -> test "encode all things" <|
Expect.equal "anobstacleisoftenasteppingstone" \() ->
(decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v") Expect.equal "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
(encode "The quick brown fox jumps over the lazy dog.")
, skip <|
test "decode word" <|
\() -> Expect.equal "exercism" (decode "vcvix rhn")
, skip <|
test "decode sentence" <|
\() ->
Expect.equal "anobstacleisoftenasteppingstone"
(decode "zmlyh gzxov rhlug vmzhg vkkrm thglm v")
] ]

View file

@ -15,101 +15,120 @@ tests =
\() -> \() ->
Expect.equal "Whatever." Expect.equal "Whatever."
(Bob.hey "Tom-ay-to, tom-aaaah-to.") (Bob.hey "Tom-ay-to, tom-aaaah-to.")
, test "shouting" <| , skip <|
\() -> test "shouting" <|
Expect.equal \() ->
"Whoa, chill out!" Expect.equal
(Bob.hey "WATCH OUT!") "Whoa, chill out!"
, test "shouting gibberish" <| (Bob.hey "WATCH OUT!")
\() -> , skip <|
Expect.equal test "shouting gibberish" <|
"Whoa, chill out!" \() ->
(Bob.hey (uppercaseGibberish 10)) Expect.equal
, test "asking a question" <| "Whoa, chill out!"
\() -> (Bob.hey (uppercaseGibberish 10))
Expect.equal , skip <|
"Sure." test "asking a question" <|
(Bob.hey "Does this cryogenic chamber make me look fat?") \() ->
, test "asking a numeric question" <| Expect.equal
\() -> "Sure."
Expect.equal (Bob.hey "Does this cryogenic chamber make me look fat?")
"Sure." , skip <|
(Bob.hey "You are, what, like 15?") test "asking a numeric question" <|
, test "asking gibberish" <| \() ->
\() -> Expect.equal
Expect.equal "Sure."
"Sure." (Bob.hey "You are, what, like 15?")
(Bob.hey (gibberishQuestion 20)) , skip <|
, test "talking forcefully" <| test "asking gibberish" <|
\() -> \() ->
Expect.equal Expect.equal
"Whatever." "Sure."
(Bob.hey "Let's go make out behind the gym!") (Bob.hey (gibberishQuestion 20))
, test "using acronyms in regular speech" <| , skip <|
\() -> test "talking forcefully" <|
Expect.equal \() ->
"Whatever." Expect.equal
(Bob.hey "It's OK if you don't want to go to the DMV.") "Whatever."
, test "forceful questions" <| (Bob.hey "Let's go make out behind the gym!")
\() -> , skip <|
Expect.equal test "using acronyms in regular speech" <|
"Whoa, chill out!" \() ->
(Bob.hey "WHAT THE HELL WERE YOU THINKING?") Expect.equal
, test "shouting numbers" <| "Whatever."
\() -> (Bob.hey "It's OK if you don't want to go to the DMV.")
Expect.equal , skip <|
"Whoa, chill out!" test "forceful questions" <|
(Bob.hey "1, 2, 3 GO!") \() ->
, test "only numbers" <| Expect.equal
\() -> "Whoa, chill out!"
Expect.equal (Bob.hey "WHAT THE HELL WERE YOU THINKING?")
"Whatever." , skip <|
(Bob.hey "1, 2, 3") test "shouting numbers" <|
, test "question with only numbers" <| \() ->
\() -> Expect.equal
Expect.equal "Whoa, chill out!"
"Sure." (Bob.hey "1, 2, 3 GO!")
(Bob.hey "4?") , skip <|
, test "shouting with special characters" <| test "only numbers" <|
\() -> \() ->
Expect.equal Expect.equal
"Whoa, chill out!" "Whatever."
(Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!") (Bob.hey "1, 2, 3")
, test "shouting with no exclamation mark" <| , skip <|
\() -> test "question with only numbers" <|
Expect.equal \() ->
"Whoa, chill out!" Expect.equal
(Bob.hey "I HATE YOU") "Sure."
, test "statement containing a question mark" <| (Bob.hey "4?")
\() -> , skip <|
Expect.equal test "shouting with special characters" <|
"Whatever." \() ->
(Bob.hey "Ending with ? means a question.") Expect.equal
, test "prattling on" <| "Whoa, chill out!"
\() -> (Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
Expect.equal , skip <|
"Sure." test "shouting with no exclamation mark" <|
(Bob.hey "Wait! Hang on. Are you going to be OK?") \() ->
, test "silence" <| Expect.equal
\() -> "Whoa, chill out!"
Expect.equal (Bob.hey "I HATE YOU")
"Fine. Be that way!" , skip <|
(Bob.hey "") test "statement containing a question mark" <|
, test "prolonged silence" <| \() ->
\() -> Expect.equal
Expect.equal "Whatever."
"Fine. Be that way!" (Bob.hey "Ending with ? means a question.")
(Bob.hey " ") , skip <|
, test "alternate silences" <| test "prattling on" <|
\() -> \() ->
Expect.equal Expect.equal
"Fine. Be that way!" "Sure."
(Bob.hey "\t \n \t ") (Bob.hey "Wait! Hang on. Are you going to be OK?")
, test "on multiple line questions" <| , skip <|
\() -> test "silence" <|
Expect.equal \() ->
"Whatever." Expect.equal
(Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno") "Fine. Be that way!"
(Bob.hey "")
, skip <|
test "prolonged silence" <|
\() ->
Expect.equal
"Fine. Be that way!"
(Bob.hey " ")
, skip <|
test "alternate silences" <|
\() ->
Expect.equal
"Fine. Be that way!"
(Bob.hey "\t \n \t ")
, skip <|
test "on multiple line questions" <|
\() ->
Expect.equal
"Whatever."
(Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno")
] ]

View file

@ -11,27 +11,36 @@ tests =
[ describe "square the sum of the numbers up to the given number" [ describe "square the sum of the numbers up to the given number"
[ test "square of sum 5" <| [ test "square of sum 5" <|
\() -> Expect.equal 225 (squareOfSum 5) \() -> Expect.equal 225 (squareOfSum 5)
, test "square of sum 10" <| , skip <|
\() -> Expect.equal 3025 (squareOfSum 10) test "square of sum 10" <|
, test "square of sum 100" <| \() -> Expect.equal 3025 (squareOfSum 10)
\() -> Expect.equal 25502500 (squareOfSum 100) , skip <|
test "square of sum 100" <|
\() -> Expect.equal 25502500 (squareOfSum 100)
] ]
, describe "sum the squares of the numbers up to the given number" , describe "sum the squares of the numbers up to the given number"
[ test "sum of squares 5" <| [ skip <|
\() -> Expect.equal 55 (sumOfSquares 5) test "sum of squares 5" <|
, test "sum of squares 10" <| \() -> Expect.equal 55 (sumOfSquares 5)
\() -> Expect.equal 385 (sumOfSquares 10) , skip <|
, test "sum of squares 100" <| test "sum of squares 10" <|
\() -> Expect.equal 338350 (sumOfSquares 100) \() -> Expect.equal 385 (sumOfSquares 10)
, skip <|
test "sum of squares 100" <|
\() -> Expect.equal 338350 (sumOfSquares 100)
] ]
, describe "subtract sum of squares from square of sums" , describe "subtract sum of squares from square of sums"
[ test "difference of squares 0" <| [ skip <|
\() -> Expect.equal 0 (difference 0) test "difference of squares 0" <|
, test "difference of squares 5" <| \() -> Expect.equal 0 (difference 0)
\() -> Expect.equal 170 (difference 5) , skip <|
, test "difference of squares 10" <| test "difference of squares 5" <|
\() -> Expect.equal 2640 (difference 10) \() -> Expect.equal 170 (difference 5)
, test "difference of squares 100" <| , skip <|
\() -> Expect.equal 25164150 (difference 100) test "difference of squares 10" <|
\() -> Expect.equal 2640 (difference 10)
, skip <|
test "difference of squares 100" <|
\() -> Expect.equal 25164150 (difference 100)
] ]
] ]

View file

@ -13,18 +13,22 @@ tests =
[ test "2011-04-25" <| [ test "2011-04-25" <|
\() -> \() ->
Expect.equal (date "2043-01-01T01:46:40") (Gigasecond.add (date "2011-04-25")) Expect.equal (date "2043-01-01T01:46:40") (Gigasecond.add (date "2011-04-25"))
, test "1977-06-13" <| , skip <|
\() -> test "1977-06-13" <|
Expect.equal (date "2009-02-19T01:46:40") (Gigasecond.add (date "1977-06-13")) \() ->
, test "1959-07-19" <| Expect.equal (date "2009-02-19T01:46:40") (Gigasecond.add (date "1977-06-13"))
\() -> , skip <|
Expect.equal (date "1991-03-27T01:46:40") (Gigasecond.add (date "1959-07-19")) test "1959-07-19" <|
, test "full time specified" <| \() ->
\() -> Expect.equal (date "1991-03-27T01:46:40") (Gigasecond.add (date "1959-07-19"))
Expect.equal (date "2046-10-02T23:46:40") (Gigasecond.add (date "2015-01-24T22:00:00")) , skip <|
, test "full time with day roll-over" <| test "full time specified" <|
\() -> \() ->
Expect.equal (date "2046-10-03T01:46:39") (Gigasecond.add (date "2015-01-24T23:59:59")) Expect.equal (date "2046-10-02T23:46:40") (Gigasecond.add (date "2015-01-24T22:00:00"))
, skip <|
test "full time with day roll-over" <|
\() ->
Expect.equal (date "2046-10-03T01:46:39") (Gigasecond.add (date "2015-01-24T23:59:59"))
] ]
] ]

View file

@ -15,45 +15,50 @@ tests =
|> addStudent 2 "Aimee" |> addStudent 2 "Aimee"
|> studentsInGrade 2 |> studentsInGrade 2
) )
, test "add more students in same class" <| , skip <|
\() -> test "add more students in same class" <|
Expect.equal [ "Blair", "James", "Paul" ] \() ->
(GradeSchool.empty Expect.equal [ "Blair", "James", "Paul" ]
|> addStudent 2 "James" (GradeSchool.empty
|> addStudent 2 "Blair" |> addStudent 2 "James"
|> addStudent 2 "Paul" |> addStudent 2 "Blair"
|> studentsInGrade 2 |> addStudent 2 "Paul"
) |> studentsInGrade 2
, test "add students to different grades" <| )
\() -> , skip <|
Expect.equal [ [ "Chelsea" ], [ "Logan" ] ] test "add students to different grades" <|
(let \() ->
school = Expect.equal [ [ "Chelsea" ], [ "Logan" ] ]
GradeSchool.empty (let
|> addStudent 3 "Chelsea" school =
|> addStudent 7 "Logan" GradeSchool.empty
in |> addStudent 3 "Chelsea"
[ studentsInGrade 3 school, studentsInGrade 7 school ] |> addStudent 7 "Logan"
) in
, test "get students in a grade" <| [ studentsInGrade 3 school, studentsInGrade 7 school ]
\() -> )
Expect.equal [ "Bradley", "Franklin" ] , skip <|
(GradeSchool.empty test "get students in a grade" <|
|> addStudent 5 "Franklin" \() ->
|> addStudent 5 "Bradley" Expect.equal [ "Bradley", "Franklin" ]
|> addStudent 1 "Jeff" (GradeSchool.empty
|> studentsInGrade 5 |> addStudent 5 "Franklin"
) |> addStudent 5 "Bradley"
, test "get all students in the school" <| |> addStudent 1 "Jeff"
\() -> |> studentsInGrade 5
Expect.equal [ ( 3, [ "Kyle" ] ), ( 4, [ "Christopher", "Jennifer" ] ), ( 6, [ "Kareem" ] ) ] )
(GradeSchool.empty , skip <|
|> addStudent 4 "Jennifer" test "get all students in the school" <|
|> addStudent 6 "Kareem" \() ->
|> addStudent 4 "Christopher" Expect.equal [ ( 3, [ "Kyle" ] ), ( 4, [ "Christopher", "Jennifer" ] ), ( 6, [ "Kareem" ] ) ]
|> addStudent 3 "Kyle" (GradeSchool.empty
|> allStudents |> addStudent 4 "Jennifer"
) |> addStudent 6 "Kareem"
, test "get students in a non-existent grade" <| |> addStudent 4 "Christopher"
\() -> Expect.equal [] (studentsInGrade 1 GradeSchool.empty) |> addStudent 3 "Kyle"
|> allStudents
)
, skip <|
test "get students in a non-existent grade" <|
\() -> Expect.equal [] (studentsInGrade 1 GradeSchool.empty)
] ]

View file

@ -12,20 +12,27 @@ tests =
[ describe "square" [ describe "square"
[ test "of 1" <| [ test "of 1" <|
\() -> Expect.equal (Just 1) (square 1) \() -> Expect.equal (Just 1) (square 1)
, test "of 2" <| , skip <|
\() -> Expect.equal (Just 2) (square 2) test "of 2" <|
, test "of 3" <| \() -> Expect.equal (Just 2) (square 2)
\() -> Expect.equal (Just 4) (square 3) , skip <|
, test "of 4" <| test "of 3" <|
\() -> Expect.equal (Just 8) (square 4) \() -> Expect.equal (Just 4) (square 3)
, test "of 16" <| , skip <|
\() -> Expect.equal (Just 32768) (square 16) test "of 4" <|
, test "of 32" <| \() -> Expect.equal (Just 8) (square 4)
\() -> Expect.equal (Just 2147483648) (square 32) , skip <|
, test "square 0 raises an exception" <| test "of 16" <|
\() -> Expect.equal Nothing (square 0) \() -> Expect.equal (Just 32768) (square 16)
, test "negative square raises an exception" <| , skip <|
\() -> Expect.equal Nothing (square -1) test "of 32" <|
\() -> Expect.equal (Just 2147483648) (square 32)
, skip <|
test "square 0 raises an exception" <|
\() -> Expect.equal Nothing (square 0)
, skip <|
test "negative square raises an exception" <|
\() -> Expect.equal Nothing (square -1)
{- {-
Where are the bigger test values?!? Because Javascript's numbers Where are the bigger test values?!? Because Javascript's numbers

View file

@ -10,30 +10,43 @@ tests =
describe "Hamming" describe "Hamming"
[ test "identical strands" <| [ test "identical strands" <|
\() -> Expect.equal (Just 0) (distance "A" "A") \() -> Expect.equal (Just 0) (distance "A" "A")
, test "long identical strands" <| , skip <|
\() -> Expect.equal (Just 0) (distance "GGACTGA" "GGACTGA") test "long identical strands" <|
, test "complete distance in single nucleotide strands" <| \() -> Expect.equal (Just 0) (distance "GGACTGA" "GGACTGA")
\() -> Expect.equal (Just 1) (distance "A" "G") , skip <|
, test "complete distance in small strands" <| test "complete distance in single nucleotide strands" <|
\() -> Expect.equal (Just 2) (distance "AG" "CT") \() -> Expect.equal (Just 1) (distance "A" "G")
, test "small distance in small strands" <| , skip <|
\() -> Expect.equal (Just 1) (distance "AT" "CT") test "complete distance in small strands" <|
, test "small distance" <| \() -> Expect.equal (Just 2) (distance "AG" "CT")
\() -> Expect.equal (Just 1) (distance "GGACG" "GGTCG") , skip <|
, test "small distance in long strands" <| test "small distance in small strands" <|
\() -> Expect.equal (Just 2) (distance "ACCAGGG" "ACTATGG") \() -> Expect.equal (Just 1) (distance "AT" "CT")
, test "non-unique character in first strand" <| , skip <|
\() -> Expect.equal (Just 1) (distance "AGA" "AGG") test "small distance" <|
, test "non-unique character in second strand" <| \() -> Expect.equal (Just 1) (distance "GGACG" "GGTCG")
\() -> Expect.equal (Just 1) (distance "AGG" "AGA") , skip <|
, test "large distance" <| test "small distance in long strands" <|
\() -> Expect.equal (Just 4) (distance "GATACA" "GCATAA") \() -> Expect.equal (Just 2) (distance "ACCAGGG" "ACTATGG")
, test "large distance in off-by-one strand" <| , skip <|
\() -> Expect.equal (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT") test "non-unique character in first strand" <|
, test "empty strands" <| \() -> Expect.equal (Just 1) (distance "AGA" "AGG")
\() -> Expect.equal (Just 0) (distance "" "") , skip <|
, test "disallow first strand longer" <| test "non-unique character in second strand" <|
\() -> Expect.equal Nothing (distance "AATG" "AAA") \() -> Expect.equal (Just 1) (distance "AGG" "AGA")
, test "disallow second strand longer" <| , skip <|
\() -> Expect.equal Nothing (distance "ATA" "AGTG") test "large distance" <|
\() -> Expect.equal (Just 4) (distance "GATACA" "GCATAA")
, skip <|
test "large distance in off-by-one strand" <|
\() -> Expect.equal (Just 9) (distance "GGACGGATTCTG" "AGGACGGATTCT")
, skip <|
test "empty strands" <|
\() -> Expect.equal (Just 0) (distance "" "")
, skip <|
test "disallow first strand longer" <|
\() -> Expect.equal Nothing (distance "AATG" "AAA")
, skip <|
test "disallow second strand longer" <|
\() -> Expect.equal Nothing (distance "ATA" "AGTG")
] ]

View file

@ -11,10 +11,12 @@ tests =
[ test "Hello with no name" <| [ test "Hello with no name" <|
\() -> \() ->
Expect.equal "Hello, World!" (helloWorld Nothing) Expect.equal "Hello, World!" (helloWorld Nothing)
, test "Hello to a sample name" <| , skip <|
\() -> test "Hello to a sample name" <|
Expect.equal "Hello, Alice!" (helloWorld (Just "Alice")) \() ->
, test "Hello to another sample name" <| Expect.equal "Hello, Alice!" (helloWorld (Just "Alice"))
\() -> , skip <|
Expect.equal "Hello, Bob!" (helloWorld (Just "Bob")) test "Hello to another sample name" <|
\() ->
Expect.equal "Hello, Bob!" (helloWorld (Just "Bob"))
] ]

View file

@ -10,36 +10,52 @@ tests =
describe "largestProduct" describe "largestProduct"
[ test "can find the largest product of 2 with numbers in order" <| [ test "can find the largest product of 2 with numbers in order" <|
\() -> Expect.equal (Just 72) (largestProduct 2 "0123456789") \() -> Expect.equal (Just 72) (largestProduct 2 "0123456789")
, test "can find the largest product of 2" <| , skip <|
\() -> Expect.equal (Just 48) (largestProduct 2 "576802143") test "can find the largest product of 2" <|
, test "finds the largest product if span equals length" <| \() -> Expect.equal (Just 48) (largestProduct 2 "576802143")
\() -> Expect.equal (Just 18) (largestProduct 2 "29") , skip <|
, test "can find the largest product of 3 with numbers in order" <| test "finds the largest product if span equals length" <|
\() -> Expect.equal (Just 504) (largestProduct 3 "0123456789") \() -> Expect.equal (Just 18) (largestProduct 2 "29")
, test "can find the largest product of 3" <| , skip <|
\() -> Expect.equal (Just 270) (largestProduct 3 "1027839564") test "can find the largest product of 3 with numbers in order" <|
, test "can find the largest product of 5 with numbers in order" <| \() -> Expect.equal (Just 504) (largestProduct 3 "0123456789")
\() -> Expect.equal (Just 15120) (largestProduct 5 "0123456789") , skip <|
, test "can get the largest product of a big number" <| test "can find the largest product of 3" <|
\() -> Expect.equal (Just 23520) (largestProduct 6 "73167176531330624919225119674426574742355349194934") \() -> Expect.equal (Just 270) (largestProduct 3 "1027839564")
, test "can get the largest product of a big number II" <| , skip <|
\() -> Expect.equal (Just 28350) (largestProduct 6 "52677741234314237566414902593461595376319419139427") test "can find the largest product of 5 with numbers in order" <|
, test "can get the largest product of a big number (Project Euler)" <| \() -> Expect.equal (Just 15120) (largestProduct 5 "0123456789")
\() -> Expect.equal (Just 23514624000) (largestProduct 13 "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450") , skip <|
, test "reports zero if the only digits are zero" <| test "can get the largest product of a big number" <|
\() -> Expect.equal (Just 0) (largestProduct 2 "0000") \() -> Expect.equal (Just 23520) (largestProduct 6 "73167176531330624919225119674426574742355349194934")
, test "reports zero if all spans include zero" <| , skip <|
\() -> Expect.equal (Just 0) (largestProduct 3 "99099") test "can get the largest product of a big number II" <|
, test "rejects span longer than string length" <| \() -> Expect.equal (Just 28350) (largestProduct 6 "52677741234314237566414902593461595376319419139427")
\() -> Expect.equal Nothing (largestProduct 4 "123") , skip <|
, test "reports 1 for empty string and empty product (0 span)" <| test "can get the largest product of a big number (Project Euler)" <|
\() -> Expect.equal (Just 1) (largestProduct 0 "") \() -> Expect.equal (Just 23514624000) (largestProduct 13 "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450")
, test "reports 1 for nonempty string and empty product (0 span)" <| , skip <|
\() -> Expect.equal (Just 1) (largestProduct 0 "123") test "reports zero if the only digits are zero" <|
, test "rejects empty string and nonzero span" <| \() -> Expect.equal (Just 0) (largestProduct 2 "0000")
\() -> Expect.equal Nothing (largestProduct 1 "") , skip <|
, test "rejects invalid character in digits" <| test "reports zero if all spans include zero" <|
\() -> Expect.equal Nothing (largestProduct 2 "1234a5") \() -> Expect.equal (Just 0) (largestProduct 3 "99099")
, test "rejects negative span" <| , skip <|
\() -> Expect.equal Nothing (largestProduct -1 "12345") test "rejects span longer than string length" <|
\() -> Expect.equal Nothing (largestProduct 4 "123")
, skip <|
test "reports 1 for empty string and empty product (0 span)" <|
\() -> Expect.equal (Just 1) (largestProduct 0 "")
, skip <|
test "reports 1 for nonempty string and empty product (0 span)" <|
\() -> Expect.equal (Just 1) (largestProduct 0 "123")
, skip <|
test "rejects empty string and nonzero span" <|
\() -> Expect.equal Nothing (largestProduct 1 "")
, skip <|
test "rejects invalid character in digits" <|
\() -> Expect.equal Nothing (largestProduct 2 "1234a5")
, skip <|
test "rejects negative span" <|
\() -> Expect.equal Nothing (largestProduct -1 "12345")
] ]

View file

@ -10,16 +10,22 @@ tests =
describe "Leap" describe "Leap"
[ test "leap year" <| [ test "leap year" <|
\() -> Expect.equal True (Leap.isLeapYear 1996) \() -> Expect.equal True (Leap.isLeapYear 1996)
, test "non-leap year" <| , skip <|
\() -> Expect.equal False (Leap.isLeapYear 1997) test "non-leap year" <|
, test "non-leap even year" <| \() -> Expect.equal False (Leap.isLeapYear 1997)
\() -> Expect.equal False (Leap.isLeapYear 1998) , skip <|
, test "century" <| test "non-leap even year" <|
\() -> Expect.equal False (Leap.isLeapYear 1900) \() -> Expect.equal False (Leap.isLeapYear 1998)
, test "second century" <| , skip <|
\() -> Expect.equal False (Leap.isLeapYear 1800) test "century" <|
, test "fourth century" <| \() -> Expect.equal False (Leap.isLeapYear 1900)
\() -> Expect.equal True (Leap.isLeapYear 2400) , skip <|
, test "y2k" <| test "second century" <|
\() -> Expect.equal True (Leap.isLeapYear 2000) \() -> Expect.equal False (Leap.isLeapYear 1800)
, skip <|
test "fourth century" <|
\() -> Expect.equal True (Leap.isLeapYear 2400)
, skip <|
test "y2k" <|
\() -> Expect.equal True (Leap.isLeapYear 2000)
] ]

View file

@ -11,57 +11,76 @@ tests =
[ describe "length" [ describe "length"
[ test "empty list" <| [ test "empty list" <|
\() -> Expect.equal 0 (ListOps.length []) \() -> Expect.equal 0 (ListOps.length [])
, test "non-empty list" <| , skip <|
\() -> Expect.equal 4 (ListOps.length (List.range 1 4)) test "non-empty list" <|
\() -> Expect.equal 4 (ListOps.length (List.range 1 4))
] ]
, describe "reverse" , describe "reverse"
[ test "empty list" <| [ skip <|
\() -> Expect.equal [] (ListOps.reverse []) test "empty list" <|
, test "non-empty list" <| \() -> Expect.equal [] (ListOps.reverse [])
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse (List.range 1 4)) , skip <|
test "non-empty list" <|
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.reverse (List.range 1 4))
] ]
, describe "map" , describe "map"
[ test "empty list" <| [ skip <|
\() -> Expect.equal [] (ListOps.map ((+) 1) []) test "empty list" <|
, test "non-empty list" <| \() -> Expect.equal [] (ListOps.map ((+) 1) [])
\() -> Expect.equal (List.range 2 5) (ListOps.map ((+) 1) (List.range 1 4)) , skip <|
test "non-empty list" <|
\() -> Expect.equal (List.range 2 5) (ListOps.map ((+) 1) (List.range 1 4))
] ]
, describe "filter" , describe "filter"
[ test "empty list" <| [ skip <|
\() -> Expect.equal [] (ListOps.filter (\_ -> True) []) test "empty list" <|
, test "non-empty list" <| \() -> Expect.equal [] (ListOps.filter (\_ -> True) [])
\() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) (List.range 1 4)) , skip <|
test "non-empty list" <|
\() -> Expect.equal [ 2, 4 ] (ListOps.filter (\x -> x % 2 == 0) (List.range 1 4))
] ]
, describe "foldl" , describe "foldl"
[ test "empty list" <| [ skip <|
\() -> Expect.equal 0 (ListOps.foldl (+) 0 []) test "empty list" <|
, test "non-empty list" <| \() -> Expect.equal 0 (ListOps.foldl (+) 0 [])
\() -> Expect.equal 10 (ListOps.foldl (+) 0 (List.range 1 4)) , skip <|
, test "direction" <| test "non-empty list" <|
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] (List.range 1 4)) \() -> Expect.equal 10 (ListOps.foldl (+) 0 (List.range 1 4))
, skip <|
test "direction" <|
\() -> Expect.equal [ 4, 3, 2, 1 ] (ListOps.foldl (::) [] (List.range 1 4))
] ]
, describe "foldr" , describe "foldr"
[ test "empty list" <| [ skip <|
\() -> Expect.equal 0 (ListOps.foldr (+) 0 []) test "empty list" <|
, test "non-empty list" <| \() -> Expect.equal 0 (ListOps.foldr (+) 0 [])
\() -> Expect.equal 10 (ListOps.foldr (+) 0 (List.range 1 4)) , skip <|
, test "direction" <| test "non-empty list" <|
\() -> Expect.equal (List.range 1 4) (ListOps.foldr (::) [] (List.range 1 4)) \() -> Expect.equal 10 (ListOps.foldr (+) 0 (List.range 1 4))
, skip <|
test "direction" <|
\() -> Expect.equal (List.range 1 4) (ListOps.foldr (::) [] (List.range 1 4))
] ]
, describe "append" , describe "append"
[ test "empty lists" <| [ skip <|
\() -> Expect.equal [] (ListOps.append [] []) test "empty lists" <|
, test "empty and non-empty lists" <| \() -> Expect.equal [] (ListOps.append [] [])
\() -> Expect.equal (List.range 1 4) (ListOps.append [] (List.range 1 4)) , skip <|
, test "non-empty and empty lists" <| test "empty and non-empty lists" <|
\() -> Expect.equal (List.range 1 4) (ListOps.append (List.range 1 4) []) \() -> Expect.equal (List.range 1 4) (ListOps.append [] (List.range 1 4))
, test "non-empty lists" <| , skip <|
\() -> Expect.equal (List.range 1 8) (ListOps.append (List.range 1 4) (List.range 5 8)) test "non-empty and empty lists" <|
\() -> Expect.equal (List.range 1 4) (ListOps.append (List.range 1 4) [])
, skip <|
test "non-empty lists" <|
\() -> Expect.equal (List.range 1 8) (ListOps.append (List.range 1 4) (List.range 5 8))
] ]
, describe "concat" , describe "concat"
[ test "empty list" <| [ skip <|
\() -> Expect.equal [] (ListOps.concat []) test "empty list" <|
, test "list of lists" <| \() -> Expect.equal [] (ListOps.concat [])
\() -> Expect.equal (List.range 1 10) (ListOps.concat [ List.range 1 3, [], List.range 4 7, List.range 8 10 ]) , skip <|
test "list of lists" <|
\() -> Expect.equal (List.range 1 10) (ListOps.concat [ List.range 1 3, [], List.range 4 7, List.range 8 10 ])
] ]
] ]

View file

@ -10,16 +10,19 @@ tests =
describe "NucleotideCount" describe "NucleotideCount"
[ test "the solution is for the correct version of the test" <| [ test "the solution is for the correct version of the test" <|
\() -> Expect.equal 2 version \() -> Expect.equal 2 version
, test "empty dna strand has no nucleotides" <| , skip <|
\() -> test "empty dna strand has no nucleotides" <|
Expect.equal { a = 0, t = 0, c = 0, g = 0 } \() ->
(nucleotideCounts "") Expect.equal { a = 0, t = 0, c = 0, g = 0 }
, test "repetitive sequence has only guanine" <| (nucleotideCounts "")
\() -> , skip <|
Expect.equal { a = 0, t = 0, c = 0, g = 8 } test "repetitive sequence has only guanine" <|
(nucleotideCounts "GGGGGGGG") \() ->
, test "counts all nucleotides" <| Expect.equal { a = 0, t = 0, c = 0, g = 8 }
\() -> (nucleotideCounts "GGGGGGGG")
Expect.equal { a = 20, t = 21, c = 12, g = 17 } , skip <|
(nucleotideCounts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC") test "counts all nucleotides" <|
\() ->
Expect.equal { a = 20, t = 21, c = 12, g = 17 }
(nucleotideCounts "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")
] ]

View file

@ -12,40 +12,49 @@ tests =
\() -> \() ->
Expect.equal False Expect.equal False
(isPangram "") (isPangram "")
, test "pangram with only lower case" <| , skip <|
\() -> test "pangram with only lower case" <|
Expect.equal True \() ->
(isPangram "the quick brown fox jumps over the lazy dog") Expect.equal True
, test "missing character 'x'" <| (isPangram "the quick brown fox jumps over the lazy dog")
\() -> , skip <|
Expect.equal False test "missing character 'x'" <|
(isPangram "a quick movement of the enemy will jeopardize five gunboats") \() ->
, test "missing character 'z'" <| Expect.equal False
\() -> (isPangram "a quick movement of the enemy will jeopardize five gunboats")
Expect.equal False , skip <|
(isPangram "a quick movement of the enemy will jeopardixe five gunboats") test "missing character 'z'" <|
, test "another missing character 'x'" <| \() ->
\() -> Expect.equal False
Expect.equal False (isPangram "a quick movement of the enemy will jeopardixe five gunboats")
(isPangram "the quick brown fish jumps over the lazy dog") , skip <|
, test "pangram with underscores" <| test "another missing character 'x'" <|
\() -> \() ->
Expect.equal True Expect.equal False
(isPangram "the_quick_brown_fox_jumps_over_the_lazy_dog") (isPangram "the quick brown fish jumps over the lazy dog")
, test "pangram with numbers" <| , skip <|
\() -> test "pangram with underscores" <|
Expect.equal True \() ->
(isPangram "the 1 quick brown fox jumps over the 2 lazy dogs") Expect.equal True
, test "missing letters replaced by numbers" <| (isPangram "the_quick_brown_fox_jumps_over_the_lazy_dog")
\() -> , skip <|
Expect.equal False test "pangram with numbers" <|
(isPangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog") \() ->
, test "pangram with mixed case and punctuation" <| Expect.equal True
\() -> (isPangram "the 1 quick brown fox jumps over the 2 lazy dogs")
Expect.equal True , skip <|
(isPangram "\"Five quacking Zephyrs jolt my wax bed.\"") test "missing letters replaced by numbers" <|
, test "pangram with non ascii characters" <| \() ->
\() -> Expect.equal False
Expect.equal True (isPangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")
(isPangram "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.") , skip <|
test "pangram with mixed case and punctuation" <|
\() ->
Expect.equal True
(isPangram "\"Five quacking Zephyrs jolt my wax bed.\"")
, skip <|
test "pangram with non ascii characters" <|
\() ->
Expect.equal True
(isPangram "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.")
] ]

View file

@ -10,26 +10,37 @@ tests =
describe "PhoneNumber" describe "PhoneNumber"
[ test "cleans number" <| [ test "cleans number" <|
\() -> Expect.equal (Just "1234567890") (getNumber "(123) 456-7890") \() -> Expect.equal (Just "1234567890") (getNumber "(123) 456-7890")
, test "cleans number with dots" <| , skip <|
\() -> Expect.equal (Just "1234567890") (getNumber "123.456.7890") test "cleans number with dots" <|
, test "valid when 11 digits and first is 1" <| \() -> Expect.equal (Just "1234567890") (getNumber "123.456.7890")
\() -> Expect.equal (Just "1234567890") (getNumber "11234567890") , skip <|
, test "invalid when 11 digits" <| test "valid when 11 digits and first is 1" <|
\() -> Expect.equal Nothing (getNumber "21234567890") \() -> Expect.equal (Just "1234567890") (getNumber "11234567890")
, test "invalid when 9 digits" <| , skip <|
\() -> Expect.equal Nothing (getNumber "123456789") test "invalid when 11 digits" <|
, test "invalid when 12 digits" <| \() -> Expect.equal Nothing (getNumber "21234567890")
\() -> Expect.equal Nothing (getNumber "123456789012") , skip <|
, test "invalid when empty" <| test "invalid when 9 digits" <|
\() -> Expect.equal Nothing (getNumber "") \() -> Expect.equal Nothing (getNumber "123456789")
, test "invalid when no digits present" <| , skip <|
\() -> Expect.equal Nothing (getNumber " (-) ") test "invalid when 12 digits" <|
, test "valid with leading characters" <| \() -> Expect.equal Nothing (getNumber "123456789012")
\() -> Expect.equal (Just "1234567890") (getNumber "my number is 123 456 7890") , skip <|
, test "valid with trailing characters" <| test "invalid when empty" <|
\() -> Expect.equal (Just "1234567890") (getNumber "123 456 7890 - bob") \() -> Expect.equal Nothing (getNumber "")
, test "pretty print" <| , skip <|
\() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "1234567890") test "invalid when no digits present" <|
, test "pretty print with full us phone number" <| \() -> Expect.equal Nothing (getNumber " (-) ")
\() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "11234567890") , skip <|
test "valid with leading characters" <|
\() -> Expect.equal (Just "1234567890") (getNumber "my number is 123 456 7890")
, skip <|
test "valid with trailing characters" <|
\() -> Expect.equal (Just "1234567890") (getNumber "123 456 7890 - bob")
, skip <|
test "pretty print" <|
\() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "1234567890")
, skip <|
test "pretty print with full us phone number" <|
\() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "11234567890")
] ]

View file

@ -10,32 +10,46 @@ tests =
describe "Raindrops" describe "Raindrops"
[ test "1" <| [ test "1" <|
\() -> Expect.equal "1" (raindrops 1) \() -> Expect.equal "1" (raindrops 1)
, test "3" <| , skip <|
\() -> Expect.equal "Pling" (raindrops 3) test "3" <|
, test "5" <| \() -> Expect.equal "Pling" (raindrops 3)
\() -> Expect.equal "Plang" (raindrops 5) , skip <|
, test "7" <| test "5" <|
\() -> Expect.equal "Plong" (raindrops 7) \() -> Expect.equal "Plang" (raindrops 5)
, test "6" <| , skip <|
\() -> Expect.equal "Pling" (raindrops 6) test "7" <|
, test "9" <| \() -> Expect.equal "Plong" (raindrops 7)
\() -> Expect.equal "Pling" (raindrops 9) , skip <|
, test "10" <| test "6" <|
\() -> Expect.equal "Plang" (raindrops 10) \() -> Expect.equal "Pling" (raindrops 6)
, test "14" <| , skip <|
\() -> Expect.equal "Plong" (raindrops 14) test "9" <|
, test "15" <| \() -> Expect.equal "Pling" (raindrops 9)
\() -> Expect.equal "PlingPlang" (raindrops 15) , skip <|
, test "21" <| test "10" <|
\() -> Expect.equal "PlingPlong" (raindrops 21) \() -> Expect.equal "Plang" (raindrops 10)
, test "25" <| , skip <|
\() -> Expect.equal "Plang" (raindrops 25) test "14" <|
, test "35" <| \() -> Expect.equal "Plong" (raindrops 14)
\() -> Expect.equal "PlangPlong" (raindrops 35) , skip <|
, test "49" <| test "15" <|
\() -> Expect.equal "Plong" (raindrops 49) \() -> Expect.equal "PlingPlang" (raindrops 15)
, test "52" <| , skip <|
\() -> Expect.equal "52" (raindrops 52) test "21" <|
, test "105" <| \() -> Expect.equal "PlingPlong" (raindrops 21)
\() -> Expect.equal "PlingPlangPlong" (raindrops 105) , skip <|
test "25" <|
\() -> Expect.equal "Plang" (raindrops 25)
, skip <|
test "35" <|
\() -> Expect.equal "PlangPlong" (raindrops 35)
, skip <|
test "49" <|
\() -> Expect.equal "Plong" (raindrops 49)
, skip <|
test "52" <|
\() -> Expect.equal "52" (raindrops 52)
, skip <|
test "105" <|
\() -> Expect.equal "PlingPlangPlong" (raindrops 105)
] ]

View file

@ -10,16 +10,22 @@ tests =
describe "RNATranscription" describe "RNATranscription"
[ test "complement of cytosine is guanine" <| [ test "complement of cytosine is guanine" <|
\() -> Expect.equal (Ok "G") (toRNA "C") \() -> Expect.equal (Ok "G") (toRNA "C")
, test "complement of guanine is cytosine" <| , skip <|
\() -> Expect.equal (Ok "C") (toRNA "G") test "complement of guanine is cytosine" <|
, test "complement of thymine is adenine" <| \() -> Expect.equal (Ok "C") (toRNA "G")
\() -> Expect.equal (Ok "A") (toRNA "T") , skip <|
, test "complement of adenine is uracil" <| test "complement of thymine is adenine" <|
\() -> Expect.equal (Ok "U") (toRNA "A") \() -> Expect.equal (Ok "A") (toRNA "T")
, test "complement" <| , skip <|
\() -> Expect.equal (Ok "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA") test "complement of adenine is uracil" <|
, test "correctly handles completely invalid input" <| \() -> Expect.equal (Ok "U") (toRNA "A")
\() -> Expect.equal (Err 'X') (toRNA "XXX") , skip <|
, test "correctly handles partially invalid input" <| test "complement" <|
\() -> Expect.equal (Err 'U') (toRNA "UGAAXXXGACAUG") \() -> Expect.equal (Ok "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA")
, skip <|
test "correctly handles completely invalid input" <|
\() -> Expect.equal (Err 'X') (toRNA "XXX")
, skip <|
test "correctly handles partially invalid input" <|
\() -> Expect.equal (Err 'U') (toRNA "UGAAXXXGACAUG")
] ]

View file

@ -15,8 +15,9 @@ tests =
in in
[ test "coordinates" <| [ test "coordinates" <|
\() -> Expect.equal { x = 0, y = 0 } robot.coordinates \() -> Expect.equal { x = 0, y = 0 } robot.coordinates
, test "bearing" <| , skip <|
\() -> Expect.equal North robot.bearing test "bearing" <|
\() -> Expect.equal North robot.bearing
] ]
) )
, describe "setup" , describe "setup"
@ -24,10 +25,12 @@ tests =
robot = robot =
Robot South { x = -1, y = 1 } Robot South { x = -1, y = 1 }
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = -1, y = 1 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = -1, y = 1 } robot.coordinates
\() -> Expect.equal South robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal South robot.bearing
] ]
) )
, describe "turn right" , describe "turn right"
@ -35,7 +38,7 @@ tests =
|> List.scanl (\_ r -> turnRight r) defaultRobot |> List.scanl (\_ r -> turnRight r) defaultRobot
|> List.map .bearing |> List.map .bearing
|> assertionList [ North, East, South, West ] |> assertionList [ North, East, South, West ]
|> List.indexedMap (\i e -> test ("step " ++ toString i) (\() -> e)) |> List.indexedMap (\i e -> skip <| test ("step " ++ toString i) (\() -> e))
) )
, describe , describe
"turn left" "turn left"
@ -43,7 +46,7 @@ tests =
|> List.scanl (\_ r -> turnLeft r) defaultRobot |> List.scanl (\_ r -> turnLeft r) defaultRobot
|> List.map .bearing |> List.map .bearing
|> assertionList [ North, West, South, East ] |> assertionList [ North, West, South, East ]
|> List.indexedMap (\i e -> test ("step " ++ toString i) (\() -> e)) |> List.indexedMap (\i e -> skip <| test ("step " ++ toString i) (\() -> e))
) )
, describe "advance positive north" , describe "advance positive north"
(let (let
@ -51,10 +54,12 @@ tests =
Robot North { x = 0, y = 0 } Robot North { x = 0, y = 0 }
|> advance |> advance
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = 0, y = 1 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = 0, y = 1 } robot.coordinates
\() -> Expect.equal North robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal North robot.bearing
] ]
) )
, describe "advance positive east" , describe "advance positive east"
@ -63,10 +68,12 @@ tests =
Robot East { x = 0, y = 0 } Robot East { x = 0, y = 0 }
|> advance |> advance
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = 1, y = 0 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = 1, y = 0 } robot.coordinates
\() -> Expect.equal East robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal East robot.bearing
] ]
) )
, describe "advance negative south" , describe "advance negative south"
@ -75,10 +82,12 @@ tests =
Robot South { x = 0, y = 0 } Robot South { x = 0, y = 0 }
|> advance |> advance
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = 0, y = -1 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = 0, y = -1 } robot.coordinates
\() -> Expect.equal South robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal South robot.bearing
] ]
) )
, describe "advance positive west" , describe "advance positive west"
@ -87,10 +96,12 @@ tests =
Robot West { x = 0, y = 0 } Robot West { x = 0, y = 0 }
|> advance |> advance
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = -1, y = 0 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = -1, y = 0 } robot.coordinates
\() -> Expect.equal West robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal West robot.bearing
] ]
) )
, describe "simulate prog 1" , describe "simulate prog 1"
@ -99,10 +110,12 @@ tests =
Robot North { x = 0, y = 0 } Robot North { x = 0, y = 0 }
|> simulate "LAAARALA" |> simulate "LAAARALA"
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = -4, y = 1 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = -4, y = 1 } robot.coordinates
\() -> Expect.equal West robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal West robot.bearing
] ]
) )
, describe "simulate prog 2" , describe "simulate prog 2"
@ -111,8 +124,9 @@ tests =
Robot East { x = 2, y = -7 } Robot East { x = 2, y = -7 }
|> simulate "RRAAAAALA" |> simulate "RRAAAAALA"
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = -3, y = -8 } robot.coordinates test "coordinates" <|
\() -> Expect.equal { x = -3, y = -8 } robot.coordinates
, test "bearing" <| , test "bearing" <|
\() -> Expect.equal South robot.bearing \() -> Expect.equal South robot.bearing
] ]
@ -123,10 +137,12 @@ tests =
Robot South { x = 8, y = 4 } Robot South { x = 8, y = 4 }
|> simulate "LAAARRRALLLL" |> simulate "LAAARRRALLLL"
in in
[ test "coordinates" <| [ skip <|
\() -> Expect.equal { x = 11, y = 5 } robot.coordinates test "coordinates" <|
, test "bearing" <| \() -> Expect.equal { x = 11, y = 5 } robot.coordinates
\() -> Expect.equal North robot.bearing , skip <|
test "bearing" <|
\() -> Expect.equal North robot.bearing
] ]
) )
] ]

View file

@ -12,72 +12,89 @@ tests =
\() -> \() ->
Expect.equal ("I") Expect.equal ("I")
(toRoman 1) (toRoman 1)
, test "2" <| , skip <|
\() -> test "2" <|
Expect.equal ("II") \() ->
(toRoman 2) Expect.equal ("II")
, test "3" <| (toRoman 2)
\() -> , skip <|
Expect.equal ("III") test "3" <|
(toRoman 3) \() ->
, test "4" <| Expect.equal ("III")
\() -> (toRoman 3)
Expect.equal ("IV") , skip <|
(toRoman 4) test "4" <|
, test "5" <| \() ->
\() -> Expect.equal ("IV")
Expect.equal ("V") (toRoman 4)
(toRoman 5) , skip <|
, test "6" <| test "5" <|
\() -> \() ->
Expect.equal ("VI") Expect.equal ("V")
(toRoman 6) (toRoman 5)
, test "9" <| , skip <|
\() -> test "6" <|
Expect.equal ("IX") \() ->
(toRoman 9) Expect.equal ("VI")
, test "27" <| (toRoman 6)
\() -> , skip <|
Expect.equal ("XXVII") test "9" <|
(toRoman 27) \() ->
, test "48" <| Expect.equal ("IX")
\() -> (toRoman 9)
Expect.equal ("XLVIII") , skip <|
(toRoman 48) test "27" <|
, test "59" <| \() ->
\() -> Expect.equal ("XXVII")
Expect.equal ("LIX") (toRoman 27)
(toRoman 59) , skip <|
, test "93" <| test "48" <|
\() -> \() ->
Expect.equal ("XCIII") Expect.equal ("XLVIII")
(toRoman 93) (toRoman 48)
, test "141" <| , skip <|
\() -> test "59" <|
Expect.equal ("CXLI") \() ->
(toRoman 141) Expect.equal ("LIX")
, test "163" <| (toRoman 59)
\() -> , skip <|
Expect.equal ("CLXIII") test "93" <|
(toRoman 163) \() ->
, test "402" <| Expect.equal ("XCIII")
\() -> (toRoman 93)
Expect.equal ("CDII") , skip <|
(toRoman 402) test "141" <|
, test "575" <| \() ->
\() -> Expect.equal ("CXLI")
Expect.equal ("DLXXV") (toRoman 141)
(toRoman 575) , skip <|
, test "911" <| test "163" <|
\() -> \() ->
Expect.equal ("CMXI") Expect.equal ("CLXIII")
(toRoman 911) (toRoman 163)
, test "1024" <| , skip <|
\() -> test "402" <|
Expect.equal ("MXXIV") \() ->
(toRoman 1024) Expect.equal ("CDII")
, test "3000" <| (toRoman 402)
\() -> , skip <|
Expect.equal ("MMM") test "575" <|
(toRoman 3000) \() ->
Expect.equal ("DLXXV")
(toRoman 575)
, skip <|
test "911" <|
\() ->
Expect.equal ("CMXI")
(toRoman 911)
, skip <|
test "1024" <|
\() ->
Expect.equal ("MXXIV")
(toRoman 1024)
, skip <|
test "3000" <|
\() ->
Expect.equal ("MMM")
(toRoman 3000)
] ]

View file

@ -10,28 +10,36 @@ tests =
describe "RunLengthEncoding" describe "RunLengthEncoding"
[ test "the solution is for the correct version of the test" <| [ test "the solution is for the correct version of the test" <|
\() -> Expect.equal 2 version \() -> Expect.equal 2 version
, test "encode simple" <| , skip <|
\() -> Expect.equal "2A3B4C" (encode "AABBBCCCC") test "encode simple" <|
, test "decode simple" <| \() -> Expect.equal "2A3B4C" (encode "AABBBCCCC")
\() -> Expect.equal "AABBBCCCC" (decode "2A3B4C") , skip <|
, test "encode with single values" <| test "decode simple" <|
\() -> \() -> Expect.equal "AABBBCCCC" (decode "2A3B4C")
Expect.equal "12WB12W3B24WB" , skip <|
(encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB") test "encode with single values" <|
, test "decode with single values" <| \() ->
\() -> Expect.equal "12WB12W3B24WB"
Expect.equal "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" (encode "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB")
(decode "12WB12W3B24WB") , skip <|
, test "(decode (encode (...)) combination" <| test "decode with single values" <|
\() -> \() ->
Expect.equal "zzz ZZ zZ" Expect.equal "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
(decode (encode "zzz ZZ zZ")) (decode "12WB12W3B24WB")
, test "decode with a x10 value" <| , skip <|
\() -> test "(decode (encode (...)) combination" <|
Expect.equal "WWWWWWWWWW" \() ->
(decode "10W") Expect.equal "zzz ZZ zZ"
, test "encode unicode" <| (decode (encode "zzz ZZ zZ"))
\() -> Expect.equal "32" (encode "") , skip <|
, test "decode unicode" <| test "decode with a x10 value" <|
\() -> Expect.equal "" (decode "32") \() ->
Expect.equal "WWWWWWWWWW"
(decode "10W")
, skip <|
test "encode unicode" <|
\() -> Expect.equal "32" (encode "")
, skip <|
test "decode unicode" <|
\() -> Expect.equal "" (decode "32")
] ]

View file

@ -12,75 +12,91 @@ tests =
\() -> \() ->
Expect.equal (Ok "one") Expect.equal (Ok "one")
(say 1) (say 1)
, test "fourteen" <| , skip <|
\() -> test "fourteen" <|
Expect.equal (Ok "fourteen") \() ->
(say 14) Expect.equal (Ok "fourteen")
, test "twenty" <| (say 14)
\() -> , skip <|
Expect.equal (Ok "twenty") test "twenty" <|
(say 20) \() ->
, test "twenty-two" <| Expect.equal (Ok "twenty")
\() -> (say 20)
Expect.equal (Ok "twenty-two") , skip <|
(say 22) test "twenty-two" <|
, test "one hundred" <| \() ->
\() -> Expect.equal (Ok "twenty-two")
Expect.equal (Ok "one hundred") (say 22)
(say 100) , skip <|
, test "one hundred twenty" <| test "one hundred" <|
\() -> \() ->
Expect.equal (Ok "one hundred and twenty") Expect.equal (Ok "one hundred")
(say 120) (say 100)
, test "one hundred twenty-three" <| , skip <|
\() -> test "one hundred twenty" <|
Expect.equal (Ok "one hundred and twenty-three") \() ->
(say 123) Expect.equal (Ok "one hundred and twenty")
, test "one thousand" <| (say 120)
\() -> , skip <|
Expect.equal (Ok "one thousand") test "one hundred twenty-three" <|
(say 1000) \() ->
, test "one thousand two hundred thirty-four" <| Expect.equal (Ok "one hundred and twenty-three")
\() -> (say 123)
Expect.equal (Ok "one thousand two hundred and thirty-four") , skip <|
(say 1234) test "one thousand" <|
, test "one million" <| \() ->
\() -> Expect.equal (Ok "one thousand")
Expect.equal (Ok "one million") (say 1000)
(say 1000000) , skip <|
, test "one million two" <| test "one thousand two hundred thirty-four" <|
\() -> \() ->
Expect.equal (Ok "one million and two") Expect.equal (Ok "one thousand two hundred and thirty-four")
(say 1000002) (say 1234)
, test "1002345" <| , skip <|
\() -> test "one million" <|
Expect.equal (Ok "one million two thousand three hundred and forty-five") \() ->
(say 1002345) Expect.equal (Ok "one million")
, test "one billion" <| (say 1000000)
\() -> , skip <|
Expect.equal (Ok "one billion") test "one million two" <|
(say 1000000000) \() ->
, test "number too large" <| Expect.equal (Ok "one million and two")
\() -> (say 1000002)
Expect.equal (Err TooLarge) , skip <|
(say 10000000000000000) test "1002345" <|
, test "negative number" <| \() ->
\() -> Expect.equal (Ok "one million two thousand three hundred and forty-five")
Expect.equal (Err Negative) (say 1002345)
(say -42) , skip <|
, test "zero" <| test "one billion" <|
\() -> \() ->
Expect.equal (Ok "zero") Expect.equal (Ok "one billion")
(say 0) (say 1000000000)
, test "987654321123" <| , skip <|
\() -> test "number too large" <|
Expect.equal \() ->
(Ok Expect.equal (Err TooLarge)
("nine hundred and eighty-seven billion " (say 10000000000000000)
++ "six hundred and fifty-four million " , skip <|
++ "three hundred and twenty-one thousand " test "negative number" <|
++ "one hundred and twenty-three" \() ->
Expect.equal (Err Negative)
(say -42)
, skip <|
test "zero" <|
\() ->
Expect.equal (Ok "zero")
(say 0)
, skip <|
test "987654321123" <|
\() ->
Expect.equal
(Ok
("nine hundred and eighty-seven billion "
++ "six hundred and fifty-four million "
++ "three hundred and twenty-one thousand "
++ "one hundred and twenty-three"
)
) )
) (say 987654321123)
(say 987654321123)
] ]

View file

@ -10,24 +10,34 @@ tests =
describe "Grains" describe "Grains"
[ test "lowercase letter" <| [ test "lowercase letter" <|
\() -> Expect.equal 1 (scoreWord "a") \() -> Expect.equal 1 (scoreWord "a")
, test "uppercase letter" <| , skip <|
\() -> Expect.equal 1 (scoreWord "A") test "uppercase letter" <|
, test "valuable letter" <| \() -> Expect.equal 1 (scoreWord "A")
\() -> Expect.equal 4 (scoreWord "f") , skip <|
, test "short word" <| test "valuable letter" <|
\() -> Expect.equal 2 (scoreWord "at") \() -> Expect.equal 4 (scoreWord "f")
, test "short, valuable word" <| , skip <|
\() -> Expect.equal 12 (scoreWord "zoo") test "short word" <|
, test "medium word" <| \() -> Expect.equal 2 (scoreWord "at")
\() -> Expect.equal 6 (scoreWord "street") , skip <|
, test "medium, valuable word" <| test "short, valuable word" <|
\() -> Expect.equal 22 (scoreWord "quirky") \() -> Expect.equal 12 (scoreWord "zoo")
, test "long, mixed-case word" <| , skip <|
\() -> Expect.equal 41 (scoreWord "OxyphenButazone") test "medium word" <|
, test "english-like word" <| \() -> Expect.equal 6 (scoreWord "street")
\() -> Expect.equal 8 (scoreWord "pinata") , skip <|
, test "non-english letter is not scored" <| test "medium, valuable word" <|
\() -> Expect.equal 7 (scoreWord "piñata") \() -> Expect.equal 22 (scoreWord "quirky")
, test "empty input" <| , skip <|
\() -> Expect.equal 0 (scoreWord "") test "long, mixed-case word" <|
\() -> Expect.equal 41 (scoreWord "OxyphenButazone")
, skip <|
test "english-like word" <|
\() -> Expect.equal 8 (scoreWord "pinata")
, skip <|
test "non-english letter is not scored" <|
\() -> Expect.equal 7 (scoreWord "piñata")
, skip <|
test "empty input" <|
\() -> Expect.equal 0 (scoreWord "")
] ]

View file

@ -12,32 +12,39 @@ tests =
\() -> \() ->
Expect.equal (Ok [ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ] ]) Expect.equal (Ok [ [ 0 ], [ 1 ], [ 2 ], [ 3 ], [ 4 ] ])
(slices 1 "01234") (slices 1 "01234")
, test "slices of two" <| , skip <|
\() -> test "slices of two" <|
Expect.equal (Ok [ [ 9, 7 ], [ 7, 8 ], [ 8, 6 ], [ 6, 7 ], [ 7, 5 ], [ 5, 6 ], [ 6, 4 ] ]) \() ->
(slices 2 "97867564") Expect.equal (Ok [ [ 9, 7 ], [ 7, 8 ], [ 8, 6 ], [ 6, 7 ], [ 7, 5 ], [ 5, 6 ], [ 6, 4 ] ])
, test "slices of three" <| (slices 2 "97867564")
\() -> , skip <|
Expect.equal (Ok [ [ 9, 7, 8 ], [ 7, 8, 6 ], [ 8, 6, 7 ], [ 6, 7, 5 ], [ 7, 5, 6 ], [ 5, 6, 4 ] ]) test "slices of three" <|
(slices 3 "97867564") \() ->
, test "slices of four" <| Expect.equal (Ok [ [ 9, 7, 8 ], [ 7, 8, 6 ], [ 8, 6, 7 ], [ 6, 7, 5 ], [ 7, 5, 6 ], [ 5, 6, 4 ] ])
\() -> (slices 3 "97867564")
Expect.equal (Ok [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ] ]) , skip <|
(slices 4 "01234") test "slices of four" <|
, test "slices of five" <| \() ->
\() -> Expect.equal (Ok [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ] ])
Expect.equal (Ok [ [ 0, 1, 2, 3, 4 ] ]) (slices 4 "01234")
(slices 5 "01234") , skip <|
, test "overly long slice" <| test "slices of five" <|
\() -> \() ->
Expect.equal (Ok []) Expect.equal (Ok [ [ 0, 1, 2, 3, 4 ] ])
(slices 4 "012") (slices 5 "01234")
, test "overly short slice" <| , skip <|
\() -> test "overly long slice" <|
Expect.equal (Err ("Invalid size: 0")) \() ->
(slices 0 "01234") Expect.equal (Ok [])
, test "input has non numbers" <| (slices 4 "012")
\() -> , skip <|
Expect.equal (Err "could not convert string 'a' to an Int") test "overly short slice" <|
(slices 2 "0123abc") \() ->
Expect.equal (Err ("Invalid size: 0"))
(slices 0 "01234")
, skip <|
test "input has non numbers" <|
\() ->
Expect.equal (Err "could not convert string 'a' to an Int")
(slices 2 "0123abc")
] ]

View file

@ -10,18 +10,25 @@ tests =
describe "SpaceAge" describe "SpaceAge"
[ test "age in earth years" <| [ test "age in earth years" <|
\() -> Expect.equal 32 (round (ageOn Earth 1000000000)) \() -> Expect.equal 32 (round (ageOn Earth 1000000000))
, test "age in mercury years" <| , skip <|
\() -> Expect.equal 281 (round (ageOn Mercury 2134835688)) test "age in mercury years" <|
, test "age in venus years" <| \() -> Expect.equal 281 (round (ageOn Mercury 2134835688))
\() -> Expect.equal 10 (round (ageOn Venus 189839836)) , skip <|
, test "age on mars" <| test "age in venus years" <|
\() -> Expect.equal 39 (round (ageOn Mars 2329871239)) \() -> Expect.equal 10 (round (ageOn Venus 189839836))
, test "age on jupiter" <| , skip <|
\() -> Expect.equal 2 (round (ageOn Jupiter 901876382)) test "age on mars" <|
, test "age on saturn" <| \() -> Expect.equal 39 (round (ageOn Mars 2329871239))
\() -> Expect.equal 3 (round (ageOn Saturn 3000000000)) , skip <|
, test "age on uranus" <| test "age on jupiter" <|
\() -> Expect.equal 1 (round (ageOn Uranus 3210123456)) \() -> Expect.equal 2 (round (ageOn Jupiter 901876382))
, test "age on neptune" <| , skip <|
\() -> Expect.equal 2 (round (ageOn Neptune 8210123456)) test "age on saturn" <|
\() -> Expect.equal 3 (round (ageOn Saturn 3000000000))
, skip <|
test "age on uranus" <|
\() -> Expect.equal 1 (round (ageOn Uranus 3210123456))
, skip <|
test "age on neptune" <|
\() -> Expect.equal 2 (round (ageOn Neptune 8210123456))
] ]

View file

@ -33,48 +33,59 @@ tests =
\() -> \() ->
Expect.equal [] Expect.equal []
(keep lessThanTen []) (keep lessThanTen [])
, test "keep everything" <| , skip <|
\() -> test "keep everything" <|
Expect.equal [ 1, 2, 3 ] \() ->
(keep lessThanTen [ 1, 2, 3 ]) Expect.equal [ 1, 2, 3 ]
, test "keep first and last" <| (keep lessThanTen [ 1, 2, 3 ])
\() -> , skip <|
Expect.equal [ 1, 3 ] test "keep first and last" <|
(keep odd [ 1, 2, 3 ]) \() ->
, test "keep nothing" <| Expect.equal [ 1, 3 ]
\() -> (keep odd [ 1, 2, 3 ])
Expect.equal [] , skip <|
(keep even [ 1, 3, 5, 7 ]) test "keep nothing" <|
, test "keep neither first nor last" <| \() ->
\() -> Expect.equal []
Expect.equal [ 2 ] (keep even [ 1, 3, 5, 7 ])
(keep even [ 1, 2, 3 ]) , skip <|
, test "keep strings" <| test "keep neither first nor last" <|
\() -> \() ->
Expect.equal [ "zebra", "zombies", "zealot" ] Expect.equal [ 2 ]
(keep (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) (keep even [ 1, 2, 3 ])
, test "empty discard" <| , skip <|
\() -> test "keep strings" <|
Expect.equal [] \() ->
(discard lessThanTen []) Expect.equal [ "zebra", "zombies", "zealot" ]
, test "discard everything" <| (keep (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ])
\() -> , skip <|
Expect.equal [] test "empty discard" <|
(discard lessThanTen [ 1, 2, 3 ]) \() ->
, test "discard first and last" <| Expect.equal []
\() -> (discard lessThanTen [])
Expect.equal [ 2 ] , skip <|
(discard odd [ 1, 2, 3 ]) test "discard everything" <|
, test "discard nothing" <| \() ->
\() -> Expect.equal []
Expect.equal [ 1, 3, 5, 7 ] (discard lessThanTen [ 1, 2, 3 ])
(discard even [ 1, 3, 5, 7 ]) , skip <|
, test "discard neither first nor last" <| test "discard first and last" <|
\() -> \() ->
Expect.equal [ 1, 3 ] Expect.equal [ 2 ]
(discard even [ 1, 2, 3 ]) (discard odd [ 1, 2, 3 ])
, test "discard strings" <| , skip <|
\() -> test "discard nothing" <|
Expect.equal [ "apple", "banana", "cherimoya" ] \() ->
(discard (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ]) Expect.equal [ 1, 3, 5, 7 ]
(discard even [ 1, 3, 5, 7 ])
, skip <|
test "discard neither first nor last" <|
\() ->
Expect.equal [ 1, 3 ]
(discard even [ 1, 2, 3 ])
, skip <|
test "discard strings" <|
\() ->
Expect.equal [ "apple", "banana", "cherimoya" ]
(discard (isFirstLetter "z") [ "apple", "zebra", "banana", "zombies", "cherimoya", "zealot" ])
] ]

View file

@ -10,40 +10,58 @@ tests =
describe "Sublist" describe "Sublist"
[ test "the solution is for the correct version of the test" <| [ test "the solution is for the correct version of the test" <|
\() -> Expect.equal 2 version \() -> Expect.equal 2 version
, test "empty equals empty" <| , skip <|
\() -> Expect.equal Equal (sublist [] []) test "empty equals empty" <|
, test "empty is a sublist of anything" <| \() -> Expect.equal Equal (sublist [] [])
\() -> Expect.equal Sublist (sublist [] [ 1, 2 ]) , skip <|
, test "anything is a superlist of empty" <| test "empty is a sublist of anything" <|
\() -> Expect.equal Superlist (sublist [ 1, 2 ] []) \() -> Expect.equal Sublist (sublist [] [ 1, 2 ])
, test "1 is not 2" <| , skip <|
\() -> Expect.equal Unequal (sublist [ 1 ] [ 2 ]) test "anything is a superlist of empty" <|
, test "compare larger equal lists" <| \() -> Expect.equal Superlist (sublist [ 1, 2 ] [])
\() -> Expect.equal Equal (sublist [ 1, 1, 1 ] [ 1, 1, 1 ]) , skip <|
, test "sublist at start" <| test "1 is not 2" <|
\() -> Expect.equal Sublist (sublist [ 1, 2, 3 ] [ 1, 2, 3, 4, 5 ]) \() -> Expect.equal Unequal (sublist [ 1 ] [ 2 ])
, test "sublist in the middle" <| , skip <|
\() -> Expect.equal Sublist (sublist [ 4, 3, 2 ] [ 5, 4, 3, 2, 1 ]) test "compare larger equal lists" <|
, test "sublist at end" <| \() -> Expect.equal Equal (sublist [ 1, 1, 1 ] [ 1, 1, 1 ])
\() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] [ 1, 2, 3, 4, 5 ]) , skip <|
, test "partially matching sublist at start" <| test "sublist at start" <|
\() -> Expect.equal Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ]) \() -> Expect.equal Sublist (sublist [ 1, 2, 3 ] [ 1, 2, 3, 4, 5 ])
, test "sublist early in huge list" <| , skip <|
\() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] (List.range 1 100000)) test "sublist in the middle" <|
, test "huge sublist not in list" <| \() -> Expect.equal Sublist (sublist [ 4, 3, 2 ] [ 5, 4, 3, 2, 1 ])
\() -> Expect.equal Unequal (sublist (List.range 10 5001) (List.range 1 5000)) , skip <|
, test "superlist at start" <| test "sublist at end" <|
\() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ]) \() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] [ 1, 2, 3, 4, 5 ])
, test "superlist in middle" <| , skip <|
\() -> Expect.equal Superlist (sublist [ 5, 4, 3, 2, 1 ] [ 4, 3, 2 ]) test "partially matching sublist at start" <|
, test "superlist at end" <| \() -> Expect.equal Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ])
\() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 3, 4, 5 ]) , skip <|
, test "partially matching superlist at start" <| test "sublist early in huge list" <|
\() -> Expect.equal Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ]) \() -> Expect.equal Sublist (sublist [ 3, 4, 5 ] (List.range 1 100000))
, test "superlist early in huge list" <| , skip <|
\() -> Expect.equal Superlist (sublist (List.range 1 100000) [ 3, 4, 5 ]) test "huge sublist not in list" <|
, test "recurring values sublist" <| \() -> Expect.equal Unequal (sublist (List.range 10 5001) (List.range 1 5000))
\() -> Expect.equal Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ]) , skip <|
, test "recurring values unequal" <| test "superlist at start" <|
\() -> Expect.equal Unequal (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 ]) \() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ])
, skip <|
test "superlist in middle" <|
\() -> Expect.equal Superlist (sublist [ 5, 4, 3, 2, 1 ] [ 4, 3, 2 ])
, skip <|
test "superlist at end" <|
\() -> Expect.equal Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 3, 4, 5 ])
, skip <|
test "partially matching superlist at start" <|
\() -> Expect.equal Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ])
, skip <|
test "superlist early in huge list" <|
\() -> Expect.equal Superlist (sublist (List.range 1 100000) [ 3, 4, 5 ])
, skip <|
test "recurring values sublist" <|
\() -> Expect.equal Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ])
, skip <|
test "recurring values unequal" <|
\() -> Expect.equal Unequal (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 ])
] ]

View file

@ -10,14 +10,19 @@ tests =
describe "Sum Of Multiples" describe "Sum Of Multiples"
[ test "[3, 5] 15" <| [ test "[3, 5] 15" <|
\() -> Expect.equal 45 (sumOfMultiples [ 3, 5 ] 15) \() -> Expect.equal 45 (sumOfMultiples [ 3, 5 ] 15)
, test "[7, 13, 17] 20" <| , skip <|
\() -> Expect.equal 51 (sumOfMultiples [ 7, 13, 17 ] 20) test "[7, 13, 17] 20" <|
, test "[4, 6] 15" <| \() -> Expect.equal 51 (sumOfMultiples [ 7, 13, 17 ] 20)
\() -> Expect.equal 30 (sumOfMultiples [ 4, 6 ] 15) , skip <|
, test "[5, 6, 8] 150" <| test "[4, 6] 15" <|
\() -> Expect.equal 4419 (sumOfMultiples [ 5, 6, 8 ] 150) \() -> Expect.equal 30 (sumOfMultiples [ 4, 6 ] 15)
, test "[43, 47] 10000" <| , skip <|
\() -> Expect.equal 2203160 (sumOfMultiples [ 43, 47 ] 10000) test "[5, 6, 8] 150" <|
, test "[5, 25] 51" <| \() -> Expect.equal 4419 (sumOfMultiples [ 5, 6, 8 ] 150)
\() -> Expect.equal 275 (sumOfMultiples [ 5, 25 ] 51) , skip <|
test "[43, 47] 10000" <|
\() -> Expect.equal 2203160 (sumOfMultiples [ 43, 47 ] 10000)
, skip <|
test "[5, 25] 51" <|
\() -> Expect.equal 275 (sumOfMultiples [ 5, 25 ] 51)
] ]

View file

@ -10,30 +10,43 @@ tests =
describe "triangleKind" describe "triangleKind"
[ test "equilateral triangles have equal sides" <| [ test "equilateral triangles have equal sides" <|
\() -> Expect.equal (Ok Equilateral) (triangleKind 2 2 2) \() -> Expect.equal (Ok Equilateral) (triangleKind 2 2 2)
, test "larger equilateral triangles also have equal sides" <| , skip <|
\() -> Expect.equal (Ok Equilateral) (triangleKind 10 10 10) test "larger equilateral triangles also have equal sides" <|
, test "isosceles triangles have last two sides equal" <| \() -> Expect.equal (Ok Equilateral) (triangleKind 10 10 10)
\() -> Expect.equal (Ok Isosceles) (triangleKind 3 4 4) , skip <|
, test "isosceles triangles have first and last sides equal" <| test "isosceles triangles have last two sides equal" <|
\() -> Expect.equal (Ok Isosceles) (triangleKind 4 3 4) \() -> Expect.equal (Ok Isosceles) (triangleKind 3 4 4)
, test "isosceles triangles have two first sides equal" <| , skip <|
\() -> Expect.equal (Ok Isosceles) (triangleKind 4 4 3) test "isosceles triangles have first and last sides equal" <|
, test "isosceles triangles have in fact exactly two sides equal" <| \() -> Expect.equal (Ok Isosceles) (triangleKind 4 3 4)
\() -> Expect.equal (Ok Isosceles) (triangleKind 10 10 2) , skip <|
, test "scalene triangles have no equal sides" <| test "isosceles triangles have two first sides equal" <|
\() -> Expect.equal (Ok Scalene) (triangleKind 3 4 5) \() -> Expect.equal (Ok Isosceles) (triangleKind 4 4 3)
, test "scalene triangles have no equal sides at a larger scale too" <| , skip <|
\() -> Expect.equal (Ok Scalene) (triangleKind 10 11 12) test "isosceles triangles have in fact exactly two sides equal" <|
, test "scalene triangles have no equal sides at a larger scale too 2" <| \() -> Expect.equal (Ok Isosceles) (triangleKind 10 10 2)
\() -> Expect.equal (Ok Scalene) (triangleKind 5 4 2) , skip <|
, test "very small triangles are legal" <| test "scalene triangles have no equal sides" <|
\() -> Expect.equal (Ok Scalene) (triangleKind 0.4 0.6 0.3) \() -> Expect.equal (Ok Scalene) (triangleKind 3 4 5)
, test "triangles with no size are illegal" <| , skip <|
\() -> Expect.equal (Err "Invalid lengths") (triangleKind 0 0 0) test "scalene triangles have no equal sides at a larger scale too" <|
, test "triangles with negative sides are illegal" <| \() -> Expect.equal (Ok Scalene) (triangleKind 10 11 12)
\() -> Expect.equal (Err "Invalid lengths") (triangleKind 3 4 -5) , skip <|
, test "triangles violating triangle inequality are illegal 1" <| test "scalene triangles have no equal sides at a larger scale too 2" <|
\() -> Expect.equal (Err "Violates inequality") (triangleKind 1 1 3) \() -> Expect.equal (Ok Scalene) (triangleKind 5 4 2)
, test "triangles violating triangle inequality are illegal 2" <| , skip <|
\() -> Expect.equal (Err "Violates inequality") (triangleKind 7 3 2) test "very small triangles are legal" <|
\() -> Expect.equal (Ok Scalene) (triangleKind 0.4 0.6 0.3)
, skip <|
test "triangles with no size are illegal" <|
\() -> Expect.equal (Err "Invalid lengths") (triangleKind 0 0 0)
, skip <|
test "triangles with negative sides are illegal" <|
\() -> Expect.equal (Err "Invalid lengths") (triangleKind 3 4 -5)
, skip <|
test "triangles violating triangle inequality are illegal 1" <|
\() -> Expect.equal (Err "Violates inequality") (triangleKind 1 1 3)
, skip <|
test "triangles violating triangle inequality are illegal 2" <|
\() -> Expect.equal (Err "Violates inequality") (triangleKind 7 3 2)
] ]

View file

@ -13,24 +13,29 @@ tests =
\() -> \() ->
Expect.equal [ ( "word", 1 ) ] Expect.equal [ ( "word", 1 ) ]
(wordCount "word" |> Dict.toList) (wordCount "word" |> Dict.toList)
, test "count one of each word" <| , skip <|
\() -> test "count one of each word" <|
Expect.equal [ ( "each", 1 ), ( "of", 1 ), ( "one", 1 ) ] \() ->
(wordCount "one of each" |> Dict.toList) Expect.equal [ ( "each", 1 ), ( "of", 1 ), ( "one", 1 ) ]
, test "multiple occurrences of a word" <| (wordCount "one of each" |> Dict.toList)
\() -> , skip <|
Expect.equal [ ( "blue", 1 ), ( "fish", 4 ), ( "one", 1 ), ( "red", 1 ), ( "two", 1 ) ] test "multiple occurrences of a word" <|
(wordCount "one fish two fish red fish blue fish" |> Dict.toList) \() ->
, test "ignore punctuation" <| Expect.equal [ ( "blue", 1 ), ( "fish", 4 ), ( "one", 1 ), ( "red", 1 ), ( "two", 1 ) ]
\() -> (wordCount "one fish two fish red fish blue fish" |> Dict.toList)
Expect.equal [ ( "as", 1 ), ( "car", 1 ), ( "carpet", 1 ), ( "java", 1 ), ( "javascript", 1 ) ] , skip <|
(wordCount "car : carpet as java : javascript!!&@$%^&" |> Dict.toList) test "ignore punctuation" <|
, test "include numbers" <| \() ->
\() -> Expect.equal [ ( "as", 1 ), ( "car", 1 ), ( "carpet", 1 ), ( "java", 1 ), ( "javascript", 1 ) ]
Expect.equal [ ( "1", 1 ), ( "2", 1 ), ( "testing", 2 ) ] (wordCount "car : carpet as java : javascript!!&@$%^&" |> Dict.toList)
(wordCount "testing, 1, 2 testing" |> Dict.toList) , skip <|
, test "normalize case" <| test "include numbers" <|
\() -> \() ->
Expect.equal [ ( "go", 3 ), ( "stop", 2 ) ] Expect.equal [ ( "1", 1 ), ( "2", 1 ), ( "testing", 2 ) ]
(wordCount "go Go GO Stop stop" |> Dict.toList) (wordCount "testing, 1, 2 testing" |> Dict.toList)
, skip <|
test "normalize case" <|
\() ->
Expect.equal [ ( "go", 3 ), ( "stop", 2 ) ]
(wordCount "go Go GO Stop stop" |> Dict.toList)
] ]