Skip to content

Commit

Permalink
Update test dependencies to support newer test runner
Browse files Browse the repository at this point in the history
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:

+ elm-explorations/test@e3584bd (elm-explorations/test#46, elm-explorations/test#224)
+ elm-explorations/test@9aa32d9 (elm-explorations/test#48)
+ elm-explorations/test@387aa2d (elm-explorations/test#157)
  • Loading branch information
Viir committed Nov 11, 2023
1 parent d510ebb commit 5fcef0b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
51 changes: 27 additions & 24 deletions tests/BigIntTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..)
Expand Down Expand Up @@ -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)
]

Expand Down Expand Up @@ -236,27 +235,27 @@ 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))
]


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)
]
Expand All @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand All @@ -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 ->
Expand All @@ -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"
]


Expand All @@ -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)))
Expand Down

0 comments on commit 5fcef0b

Please sign in to comment.