2017-01-16 02:16:28 +03:00
|
|
|
port module NoUnannotatedFunctionTest exposing (all)
|
2017-01-16 02:07:04 +03:00
|
|
|
|
|
|
|
import Expect
|
|
|
|
import Test exposing (describe, test, Test)
|
2017-01-16 02:16:28 +03:00
|
|
|
import NoUnannotatedFunction exposing (rule)
|
2017-01-16 02:07:04 +03:00
|
|
|
import Types exposing (Error)
|
|
|
|
|
|
|
|
|
|
|
|
error : String -> Error
|
|
|
|
error =
|
2017-01-16 02:16:28 +03:00
|
|
|
Error "NoUnannotatedFunction"
|
2017-01-16 02:07:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
tests : List Test
|
|
|
|
tests =
|
|
|
|
[ test "should not report constants that are annotated" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule """
|
2017-01-16 02:07:04 +03:00
|
|
|
f : Int"
|
|
|
|
f = 2
|
|
|
|
"""
|
|
|
|
|> Expect.equal []
|
|
|
|
, test "should not report functions that are annotated" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule """
|
2017-01-16 02:07:04 +03:00
|
|
|
f : Int -> Int"
|
|
|
|
f n = 2
|
|
|
|
"""
|
|
|
|
|> Expect.equal []
|
|
|
|
, test "should report constants that are not annotated" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule "f = 2"
|
2017-01-16 02:07:04 +03:00
|
|
|
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
|
|
|
, test "should report functions that are not annotated" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule "f n = 2"
|
2017-01-16 02:07:04 +03:00
|
|
|
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
|
|
|
, test "should report functions that are not annotated" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule "f n = 2"
|
2017-01-16 02:07:04 +03:00
|
|
|
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
|
|
|
, test "should report functions that are not annotated when there are annotations" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule """
|
2017-01-16 02:07:04 +03:00
|
|
|
f : Int -> Int
|
|
|
|
g n = 3
|
|
|
|
"""
|
|
|
|
|> Expect.equal [ error "`g` does not have a type declaration" ]
|
|
|
|
, test "should report functions that are not annotated when there are other annotated functions" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule """
|
2017-01-16 02:07:04 +03:00
|
|
|
f : Int -> Int
|
|
|
|
f n = 2
|
|
|
|
|
|
|
|
g n = 3
|
|
|
|
"""
|
|
|
|
|> Expect.equal [ error "`g` does not have a type declaration" ]
|
|
|
|
, test "should not functions declared in a `let` body" <|
|
|
|
|
\() ->
|
2017-01-16 23:40:01 +03:00
|
|
|
rule """
|
2017-01-16 02:07:04 +03:00
|
|
|
f : Int -> Int
|
|
|
|
f n =
|
|
|
|
let
|
|
|
|
a = 2
|
|
|
|
in
|
|
|
|
a
|
|
|
|
"""
|
|
|
|
|> Expect.equal []
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
all : Test
|
|
|
|
all =
|
2017-01-16 02:16:28 +03:00
|
|
|
describe "NoUnannotatedFunction" tests
|