Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test dependencies to support newer test runner #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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