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)))