2017-05-28 18:50:15 +00:00
|
|
|
module Tests exposing (..)
|
2016-12-25 09:57:15 +00:00
|
|
|
|
|
|
|
import Expect
|
|
|
|
import Grains exposing (square)
|
2017-05-28 18:50:15 +00:00
|
|
|
import Json.Encode exposing (Value)
|
|
|
|
import Test exposing (..)
|
2016-12-25 09:57:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests : Test
|
|
|
|
tests =
|
|
|
|
describe "Grains"
|
|
|
|
[ describe "square"
|
|
|
|
[ test "of 1" <|
|
|
|
|
\() -> Expect.equal (Just 1) (square 1)
|
|
|
|
, test "of 2" <|
|
|
|
|
\() -> Expect.equal (Just 2) (square 2)
|
|
|
|
, test "of 3" <|
|
|
|
|
\() -> Expect.equal (Just 4) (square 3)
|
|
|
|
, test "of 4" <|
|
|
|
|
\() -> Expect.equal (Just 8) (square 4)
|
|
|
|
, test "of 16" <|
|
|
|
|
\() -> Expect.equal (Just 32768) (square 16)
|
|
|
|
, test "of 32" <|
|
|
|
|
\() -> Expect.equal (Just 2147483648) (square 32)
|
|
|
|
, test "square 0 raises an exception" <|
|
|
|
|
\() -> Expect.equal Nothing (square 0)
|
|
|
|
, test "negative square raises an exception" <|
|
|
|
|
\() -> Expect.equal Nothing (square -1)
|
|
|
|
]
|
|
|
|
]
|