From 5fcef0bd107e3c53e09c00711be1fd417cd10882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=A4tzel?= Date: Sat, 11 Nov 2023 18:39:35 +0000 Subject: [PATCH] Update test dependencies to support newer test runner Running the latest version of elm-test-rs on this project failed with the following error message: ``` Error: Failed to solve dependencies for tests to run Caused by: This version of elm-test-rs only supports elm-explorations/test 2.0.0 <= v < 3.0.0, but you have 1.1.0 <= v < 2.0.0 in your dependencies ``` The commit updates the dependencies to enable running tests with the latest version of elm-test-rs Changes in the API of the test framework required adaption of the test code. For details on changes in the test framework, see: + https://github.com/elm-explorations/test/commit/e3584bddcbba7030f39dadcd6473469d72f6e372 (https://github.com/elm-explorations/test/pull/46, https://github.com/elm-explorations/test/issues/224) + https://github.com/elm-explorations/test/commit/9aa32d9d28435d61d8c53d8b88023dd6c0bdab7e (https://github.com/elm-explorations/test/issues/48) + https://github.com/elm-explorations/test/commit/387aa2d6ed53e6389f360529ca01c557a8116289 (https://github.com/elm-explorations/test/pull/157) --- elm.json | 2 +- tests/BigIntTests.elm | 51 +++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/elm.json b/elm.json index b9fe558..4aecaf1 100644 --- a/elm.json +++ b/elm.json @@ -17,6 +17,6 @@ }, "test-dependencies": { "elm/random": "1.0.0 <= v < 2.0.0", - "elm-explorations/test": "1.1.0 <= v < 2.0.0" + "elm-explorations/test": "2.1.2 <= v < 3.0.0" } } \ No newline at end of file diff --git a/tests/BigIntTests.elm b/tests/BigIntTests.elm index 5011661..df3470f 100644 --- a/tests/BigIntTests.elm +++ b/tests/BigIntTests.elm @@ -3,9 +3,8 @@ module BigIntTests exposing (absTests, addTests, compareTests, divmodTests, from import BigInt exposing (..) import Constants exposing (maxDigitValue) import Expect -import Fuzz exposing (Fuzzer, int, intRange, tuple) +import Fuzz exposing (Fuzzer, int, intRange, pair) import Hex -import Maybe exposing (Maybe) import Random import String import Test exposing (..) @@ -189,16 +188,16 @@ roundRobinTests = addTests : Test addTests = describe "addition" - [ fuzz (tuple ( smallInt, smallInt )) "add x y = x + y for small numbers" <| + [ fuzz (pair smallInt smallInt) "add x y = x + y for small numbers" <| \( x, y ) -> add (fromInt x) (fromInt y) |> Expect.equal (fromInt (x + y)) - , fuzz (tuple ( integer, integer )) "x + y + (-y) = x" <| + , fuzz (pair integer integer) "x + y + (-y) = x" <| \( x, y ) -> add x y |> add (BigInt.negate y) |> Expect.equal x - , fuzz (tuple ( integer, integer )) "a + b = b + a" <| + , fuzz (pair integer integer) "a + b = b + a" <| \( a, b ) -> Expect.equal (add a b) (add b a) ] @@ -236,10 +235,10 @@ negateTests = subTests : Test subTests = describe "subtraction" - [ fuzz (tuple ( integer, integer )) "x - y = x + -y" <| + [ fuzz (pair integer integer) "x - y = x + -y" <| \( x, y ) -> Expect.equal (sub x y) (add x (BigInt.negate y)) - , fuzz (tuple ( integer, integer )) "a - b = -(b - a)" <| + , fuzz (pair integer integer) "a - b = -(b - a)" <| \( a, b ) -> Expect.equal (sub a b) (BigInt.negate (sub b a)) ] @@ -247,16 +246,16 @@ subTests = mulTests : Test mulTests = describe "Mul testsuite" - [ fuzz (tuple ( smallInt, smallInt )) "mult x y = x * y for small numbers" <| + [ fuzz (pair smallInt smallInt) "mult x y = x * y for small numbers" <| \( x, y ) -> mul (fromInt x) (fromInt y) |> Expect.equal (fromInt (x * y)) - , fuzz (tuple ( integer, nonZeroInteger )) "(x * y) / y = x" <| + , fuzz (pair integer nonZeroInteger) "(x * y) / y = x" <| \( x, y ) -> mul x y |> (\n -> divmod n y) |> Expect.equal (Just ( x, zero )) - , fuzz (tuple ( integer, integer )) "x * y = y * x" <| + , fuzz (pair integer integer) "x * y = y * x" <| \( x, y ) -> Expect.equal (mul x y) (mul y x) ] @@ -265,7 +264,7 @@ mulTests = divmodTests : Test divmodTests = describe "divmod" - [ fuzz (tuple ( integer, nonZeroInteger )) "definition" <| + [ fuzz (pair integer nonZeroInteger) "definition" <| \( x, y ) -> case divmod x y of Nothing -> @@ -338,7 +337,7 @@ stringTests = minTests : Test minTests = describe "min" - [ fuzz (tuple ( integer, integer )) "min x y = x; x <= y and min x y = y; x > y" <| + [ fuzz (pair integer integer) "min x y = x; x <= y and min x y = y; x > y" <| \( x, y ) -> case BigInt.compare x y of GT -> @@ -352,7 +351,7 @@ minTests = maxTests : Test maxTests = describe "max" - [ fuzz (tuple ( integer, integer )) "min x y = y; x <= y and min x y = x; x > y" <| + [ fuzz (pair integer integer) "min x y = y; x <= y and min x y = x; x > y" <| \( x, y ) -> case BigInt.compare x y of LT -> @@ -368,23 +367,27 @@ compareTests = describe "compare" [ fuzz integer "x = x" <| \x -> - Expect.true "apparently x /= x" (x == x) - , fuzz (tuple ( integer, integer )) "x <= x + y; y >= 0" <| + Expect.equal True (x == x) + |> Expect.onFail "apparently x /= x" + , fuzz (pair integer integer) "x <= x + y; y >= 0" <| \( x, y ) -> - Expect.true "apparently !(x <= x + y); y >= 0" - (lte x (add x (BigInt.abs y))) - , fuzz (tuple ( integer, integer )) "x >= x + y; y <= 0" <| + Expect.equal True (lte x (add x (BigInt.abs y))) + |> Expect.onFail "apparently !(x <= x + y); y >= 0" + , fuzz (pair integer integer) "x >= x + y; y <= 0" <| \( x, y ) -> - Expect.true "apparently !(x >= x + y); y <= 0" + Expect.equal True (gte x (add x (BigInt.abs y |> BigInt.negate))) - , fuzz (tuple ( integer, nonZeroInteger )) "x < x + y; y > 0" <| + |> Expect.onFail "apparently !(x >= x + y); y <= 0" + , fuzz (pair integer nonZeroInteger) "x < x + y; y > 0" <| \( x, y ) -> - Expect.true "apparently !(x < x + y); y > 0" + Expect.equal True (lt x (add x (BigInt.abs y))) - , fuzz (tuple ( integer, nonZeroInteger )) "x > x + y; y < 0" <| + |> Expect.onFail "apparently !(x < x + y); y > 0" + , fuzz (pair integer nonZeroInteger) "x > x + y; y < 0" <| \( x, y ) -> - Expect.true "apparently !(x > x + y); y < 0" + Expect.equal True (gt x (add x (BigInt.abs y |> BigInt.negate))) + |> Expect.onFail "apparently !(x > x + y); y < 0" ] @@ -407,7 +410,7 @@ isOddTests = powTests : Test powTests = describe "exponentiation (pow)" - [ fuzz (tuple ( tinyInt, tinyPositiveInt )) "pow x y = y ^ x for small numbers" <| + [ fuzz (pair tinyInt tinyPositiveInt) "pow x y = y ^ x for small numbers" <| \( base, exp ) -> BigInt.toString (pow (fromInt base) (fromInt exp)) |> Expect.equal (BigInt.toString (fromInt (base ^ exp)))