Added some simple tests

This commit is contained in:
John Shaver 2017-06-26 14:46:57 -07:00
parent 9f663760c4
commit fc5b4b8afe

View file

@ -2,36 +2,30 @@ module Tests exposing (..)
import Test exposing (..) import Test exposing (..)
import Expect import Expect
import Fuzz exposing (list, int, tuple, string) import AnimationHelpers exposing (calculateAnimation)
import String
all : Test all : Test
all = all =
describe "Sample Test Suite" describe "Elmman Test Suite"
[ describe "Unit test examples" [ describe "Player logic tests"
[ test "Addition" <| [ test "Animation frame calculations" <|
\() -> \() ->
Expect.equal (3 + 7) 10 Expect.equal (calculateAnimation 100 500 ( 0, 200 )) 40
, test "String.left" <| , test "Animation frame calculations 2" <|
\() -> \() ->
Expect.equal "a" (String.left 1 "abcdefg") Expect.equal (calculateAnimation 500 500 ( 0, 200 )) 200
, test "This test should fail - you should remove it" <| , test "Animation frame calculations 3" <|
\() -> \() ->
Expect.fail "Failed as expected!" Expect.equal (calculateAnimation 501 500 ( 0, 200 )) 0
] , test "Animation frame calculations 4" <|
, describe "Fuzz test examples, using randomly generated input" \() ->
[ fuzz (list int) "Lists always have positive length" <| Expect.equal (calculateAnimation 500 500 ( 100, 300 )) 300
\aList -> , test "Animation frame calculations 5" <|
List.length aList |> Expect.atLeast 0 \() ->
, fuzz (list int) "Sorting a list does not change its length" <| Expect.equal (calculateAnimation 100 500 ( 100, 300 )) 140
\aList -> , test "Animation frame calculations 6" <|
List.sort aList |> List.length |> Expect.equal (List.length aList) \() ->
, fuzzWith { runs = 1000 } int "List.member will find an integer in a list containing it" <| Expect.equal (calculateAnimation 100 500 ( -100, 100 )) -60
\i ->
List.member i [ i ] |> Expect.true "If you see this, List.member returned False!"
, fuzz2 string string "The length of a string equals the sum of its substrings' lengths" <|
\s1 s2 ->
s1 ++ s2 |> String.length |> Expect.equal (String.length s1 + String.length s2)
] ]
] ]