From e96b6610b2ce5dae26caa0bca7d0eed29d53ad94 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 30 Jun 2019 11:53:49 +0200 Subject: [PATCH] Use new test module for NoExtraBooleanComparison --- tests/NoExtraBooleanComparisonTest.elm | 76 ++++++++++++++++++-------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/tests/NoExtraBooleanComparisonTest.elm b/tests/NoExtraBooleanComparisonTest.elm index b727c7da..943247a1 100644 --- a/tests/NoExtraBooleanComparisonTest.elm +++ b/tests/NoExtraBooleanComparisonTest.elm @@ -1,9 +1,7 @@ module NoExtraBooleanComparisonTest exposing (all) -import Elm.Syntax.Range exposing (Location, Range) -import Lint.Rule as Rule exposing (Error, Rule) import Lint.Rule.NoExtraBooleanComparison exposing (rule) -import Lint.Test exposing (LintResult) +import Lint.Test2 exposing (LintResult) import Test exposing (Test, describe, test) @@ -11,7 +9,7 @@ testRule : String -> LintResult testRule string = "module A exposing (..)\n\n" ++ string - |> Lint.Test.run rule + |> Lint.Test2.run rule tests : List Test @@ -19,7 +17,7 @@ tests = [ test "should not report condition without an operator" <| \() -> testRule "a = if n then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange [] + |> Lint.Test2.expectNoErrors , test "should not report condition with integer operators" <| \() -> testRule """ @@ -28,51 +26,83 @@ b = if n <= 1 then 1 else 2 c = if n > 1 then 1 else 2 d = if n >= 1 then 1 else 2 """ - |> Lint.Test.expectErrorsWithoutRange [] + |> Lint.Test2.expectNoErrors , test "should not report condition using `not`" <| \() -> testRule "a = if not n then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange [] + |> Lint.Test2.expectNoErrors , test "should report condition with `expr == True`" <| \() -> testRule "a = if b == True then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `True`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `True`" + , under = " True " + } + ] , test "should report condition with `True == expr`" <| \() -> testRule "a = if True == b then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `True`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `True`" + , under = " True " + } + ] , test "should report condition with `expr == False`" <| \() -> testRule "a = if b == False then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `False`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `False`" + , under = " False " + } + ] , test "should report condition with `False == expr`" <| \() -> testRule "a = if False == b then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `False`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `False`" + , under = " False " + } + ] , test "should report condition with `expr /= True`" <| \() -> testRule "a = if b /= True then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `True`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `True`" + , under = " True " + } + ] , test "should report condition with `True /= expr`" <| \() -> testRule "a = if True /= b then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `True`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `True`" + , under = " True " + } + ] , test "should report condition with `expr /= False`" <| \() -> testRule "a = if b /= False then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `False`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `False`" + , under = " False " + } + ] , test "should report condition with `False /= expr`" <| \() -> testRule "a = if False /= b then 1 else 2" - |> Lint.Test.expectErrorsWithoutRange - [ Lint.Test.errorWithoutRange "Unnecessary comparison with `False`" ] + |> Lint.Test2.expectErrors + [ Lint.Test2.error + { message = "Unnecessary comparison with `False`" + , under = " False " + } + ] ]