2016-03-17 01:38:35 +00:00
|
|
|
module Main (..) where
|
2015-10-12 16:46:15 +00:00
|
|
|
|
2016-03-17 01:38:35 +00:00
|
|
|
import Task
|
|
|
|
import Console
|
|
|
|
import ElmTest exposing (..)
|
2016-04-12 20:54:11 +00:00
|
|
|
import Sublist exposing (version, sublist, ListComparison(..))
|
2015-10-12 16:46:15 +00:00
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-12 16:46:15 +00:00
|
|
|
tests : Test
|
2016-03-17 01:38:51 +00:00
|
|
|
tests =
|
|
|
|
suite
|
|
|
|
"Sublist"
|
|
|
|
[ test
|
2016-04-12 20:54:11 +00:00
|
|
|
"the solution is for the correct version of the test"
|
|
|
|
(assertEqual 2 version)
|
|
|
|
, test
|
2016-03-17 01:38:51 +00:00
|
|
|
"empty equals empty"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Equal (sublist [] []))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"empty is a sublist of anything"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [] [ 1, 2 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"anything is a superlist of empty"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [ 1, 2 ] []))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"1 is not 2"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Unequal (sublist [ 1 ] [ 2 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"compare larger equal lists"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Equal (sublist [ 1, 1, 1 ] [ 1, 1, 1 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"sublist at start"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 1, 2, 3 ] [ 1, 2, 3, 4, 5 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"sublist in the middle"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 4, 3, 2 ] [ 5, 4, 3, 2, 1 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"sublist at end"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 3, 4, 5 ] [ 1, 2, 3, 4, 5 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"partially matching sublist at start"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 1, 1, 2 ] [ 1, 1, 1, 2 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"sublist early in huge list"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 3, 4, 5 ] [1..100000]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"huge sublist not in list"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Unequal (sublist [10..100001] [1..100000]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"superlist at start"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"superlist in middle"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [ 5, 4, 3, 2, 1 ] [ 4, 3, 2 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"superlist at end"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [ 1, 2, 3, 4, 5 ] [ 3, 4, 5 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"partially matching superlist at start"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [ 1, 1, 1, 2 ] [ 1, 1, 2 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"superlist early in huge list"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Superlist (sublist [1..100000] [ 3, 4, 5 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"recurring values sublist"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Sublist (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
, test
|
|
|
|
"recurring values unequal"
|
2016-04-10 03:15:51 +00:00
|
|
|
(assertEqual Unequal (sublist [ 1, 2, 1, 2, 3 ] [ 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 ]))
|
2016-03-17 01:38:51 +00:00
|
|
|
]
|
|
|
|
|
2015-10-12 16:46:15 +00:00
|
|
|
|
2016-03-17 01:38:35 +00:00
|
|
|
port runner : Signal (Task.Task x ())
|
|
|
|
port runner =
|
|
|
|
Console.run (consoleRunner tests)
|