2016-03-17 01:38:35 +00:00
|
|
|
module Main (..) where
|
2015-10-14 19:02:13 +00:00
|
|
|
|
2016-03-17 01:38:35 +00:00
|
|
|
import Task
|
|
|
|
import Console
|
|
|
|
import ElmTest exposing (..)
|
2016-03-17 01:16:54 +00:00
|
|
|
import GradeSchool exposing (addStudent, studentsInGrade, allStudents)
|
2015-10-14 19:02:13 +00:00
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-14 19:02:13 +00:00
|
|
|
tests : Test
|
2016-03-17 01:38:51 +00:00
|
|
|
tests =
|
|
|
|
suite
|
|
|
|
"GradeSchool"
|
|
|
|
[ test
|
|
|
|
"add student"
|
|
|
|
(assertEqual
|
2016-03-17 01:16:54 +00:00
|
|
|
[ "Aimee" ]
|
|
|
|
(GradeSchool.empty
|
|
|
|
|> addStudent 2 "Aimee"
|
|
|
|
|> studentsInGrade 2
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
)
|
|
|
|
, test
|
|
|
|
"add more students in same class"
|
|
|
|
(assertEqual
|
2016-03-17 01:16:54 +00:00
|
|
|
[ "Blair", "James", "Paul" ]
|
|
|
|
(GradeSchool.empty
|
|
|
|
|> addStudent 2 "James"
|
|
|
|
|> addStudent 2 "Blair"
|
|
|
|
|> addStudent 2 "Paul"
|
|
|
|
|> studentsInGrade 2
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
)
|
|
|
|
, test
|
|
|
|
"add students to different grades"
|
|
|
|
(assertEqual
|
2016-03-17 01:16:54 +00:00
|
|
|
[ [ "Chelsea" ], [ "Logan" ] ]
|
|
|
|
(let
|
|
|
|
school =
|
|
|
|
GradeSchool.empty
|
|
|
|
|> addStudent 3 "Chelsea"
|
|
|
|
|> addStudent 7 "Logan"
|
|
|
|
in
|
|
|
|
[ studentsInGrade 3 school, studentsInGrade 7 school ]
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
)
|
|
|
|
, test
|
|
|
|
"get students in a grade"
|
|
|
|
(assertEqual
|
|
|
|
[ "Bradley", "Franklin" ]
|
2016-03-17 01:16:54 +00:00
|
|
|
(GradeSchool.empty
|
|
|
|
|> addStudent 5 "Franklin"
|
|
|
|
|> addStudent 5 "Bradley"
|
|
|
|
|> addStudent 1 "Jeff"
|
|
|
|
|> studentsInGrade 5
|
|
|
|
)
|
|
|
|
)
|
|
|
|
, test
|
|
|
|
"get all students in the school"
|
|
|
|
(assertEqual
|
|
|
|
[ ( 3, [ "Kyle" ] ), ( 4, [ "Christopher", "Jennifer" ] ), ( 6, [ "Kareem" ] ) ]
|
|
|
|
(GradeSchool.empty
|
|
|
|
|> addStudent 4 "Jennifer"
|
|
|
|
|> addStudent 6 "Kareem"
|
|
|
|
|> addStudent 4 "Christopher"
|
|
|
|
|> addStudent 3 "Kyle"
|
|
|
|
|> allStudents
|
|
|
|
)
|
2016-03-17 01:38:51 +00:00
|
|
|
)
|
|
|
|
, test
|
|
|
|
"get students in a non-existent grade"
|
2016-03-17 01:16:54 +00:00
|
|
|
(assertEqual [] (studentsInGrade 1 GradeSchool.empty))
|
2016-03-17 01:38:51 +00:00
|
|
|
]
|
2015-10-14 19:02:13 +00:00
|
|
|
|
2016-03-17 01:38:35 +00:00
|
|
|
|
|
|
|
port runner : Signal (Task.Task x ())
|
|
|
|
port runner =
|
|
|
|
Console.run (consoleRunner tests)
|