2017-05-27 17:56:31 +00:00
|
|
|
module Tests exposing (..)
|
2016-03-15 18:25:14 +00:00
|
|
|
|
2016-08-17 11:14:17 +00:00
|
|
|
import Test exposing (..)
|
|
|
|
import Expect
|
2016-02-27 17:45:34 +00:00
|
|
|
import String
|
|
|
|
import Char
|
|
|
|
import Random
|
|
|
|
import Bob
|
|
|
|
|
|
|
|
|
|
|
|
tests : Test
|
|
|
|
tests =
|
2016-08-17 11:14:17 +00:00
|
|
|
describe "Bob"
|
|
|
|
[ test "stating something" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal "Whatever."
|
|
|
|
(Bob.hey "Tom-ay-to, tom-aaaah-to.")
|
|
|
|
, test "shouting" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
|
|
|
(Bob.hey "WATCH OUT!")
|
|
|
|
, test "shouting gibberish" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
|
|
|
(Bob.hey (uppercaseGibberish 10))
|
|
|
|
, test "asking a question" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Sure."
|
|
|
|
(Bob.hey "Does this cryogenic chamber make me look fat?")
|
|
|
|
, test "asking a numeric question" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Sure."
|
|
|
|
(Bob.hey "You are, what, like 15?")
|
|
|
|
, test "asking gibberish" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Sure."
|
|
|
|
(Bob.hey (gibberishQuestion 20))
|
|
|
|
, test "talking forcefully" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whatever."
|
|
|
|
(Bob.hey "Let's go make out behind the gym!")
|
|
|
|
, test "using acronyms in regular speech" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whatever."
|
|
|
|
(Bob.hey "It's OK if you don't want to go to the DMV.")
|
|
|
|
, test "forceful questions" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
|
|
|
(Bob.hey "WHAT THE HELL WERE YOU THINKING?")
|
|
|
|
, test "shouting numbers" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
|
|
|
(Bob.hey "1, 2, 3 GO!")
|
|
|
|
, test "only numbers" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whatever."
|
|
|
|
(Bob.hey "1, 2, 3")
|
|
|
|
, test "question with only numbers" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Sure."
|
|
|
|
(Bob.hey "4?")
|
|
|
|
, test "shouting with special characters" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
2016-11-09 02:21:48 +00:00
|
|
|
(Bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")
|
2016-08-17 11:14:17 +00:00
|
|
|
, test "shouting with no exclamation mark" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whoa, chill out!"
|
|
|
|
(Bob.hey "I HATE YOU")
|
|
|
|
, test "statement containing a question mark" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whatever."
|
|
|
|
(Bob.hey "Ending with ? means a question.")
|
|
|
|
, test "prattling on" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Sure."
|
|
|
|
(Bob.hey "Wait! Hang on. Are you going to be OK?")
|
|
|
|
, test "silence" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Fine. Be that way!"
|
|
|
|
(Bob.hey "")
|
|
|
|
, test "prolonged silence" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Fine. Be that way!"
|
|
|
|
(Bob.hey " ")
|
|
|
|
, test "alternate silences" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Fine. Be that way!"
|
|
|
|
(Bob.hey "\t \n \t ")
|
|
|
|
, test "on multiple line questions" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal
|
|
|
|
"Whatever."
|
|
|
|
(Bob.hey "\nDoes this cryogenic chamber make me look fat?\nno")
|
2016-06-19 21:46:13 +00:00
|
|
|
]
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
character : Int -> Int -> Random.Generator Char
|
|
|
|
character start end =
|
2016-06-19 21:46:13 +00:00
|
|
|
Random.map Char.fromCode (Random.int start end)
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
anyCharacter : Random.Generator Char
|
|
|
|
anyCharacter =
|
2016-06-19 21:46:13 +00:00
|
|
|
character 32 126
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
uppercaseCharacter : Random.Generator Char
|
|
|
|
uppercaseCharacter =
|
2016-06-19 21:46:13 +00:00
|
|
|
character 65 90
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
listOfCharacters : Int -> Random.Generator Char -> Random.Generator (List Char)
|
|
|
|
listOfCharacters length characterList =
|
2016-06-19 21:46:13 +00:00
|
|
|
Random.list length characterList
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
gibberish : Int -> Random.Generator Char -> String
|
|
|
|
gibberish length characterList =
|
2016-12-17 22:15:34 +00:00
|
|
|
Tuple.first (Random.step (Random.map String.fromList (listOfCharacters length characterList)) (Random.initialSeed 424242))
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
uppercaseGibberish : Int -> String
|
|
|
|
uppercaseGibberish length =
|
2016-06-19 21:46:13 +00:00
|
|
|
gibberish length uppercaseCharacter
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
gibberishQuestion : Int -> String
|
|
|
|
gibberishQuestion length =
|
2016-06-19 21:46:13 +00:00
|
|
|
(gibberish length anyCharacter) ++ "?"
|