Suppose a! = B with Elm fuzz tests

I just wrote a fuzz test, which basically checks that two calls to the same function with different inputs give different results. I would like to tell Elm-test that the input cannot be equal; otherwise, this test has a low probability of failure.

I do not want them to be equal, taking the second input from the first, since this greatly limits the search space.

How do I tell the Elm-test fluxer that the two inputs it generates should not be equal?

EDIT:
Here is one of the sanity tests I wrote:

fuzz3 Fuzz.string Fuzz.int Fuzz.int "Decryption is not possible with wrong key" <|
  \msg keySeed keySeed2 ->
    let
      key =
        createKey keySeed

      key2 =
        createKey keySeed2
    in
      let
        encryptedMessage =
          encrypt key msg
      in
        Expect.equal Nothing (decrypt key2 encryptedMessage)
+4
source share
1 answer

You can create a fuzzer that generates a tuple with unique values, such as:

uniqueTuple : Fuzzer comparable -> Fuzzer (comparable, comparable)
uniqueTuple fuzzer =
    let
        uniquer (a, b) =
            if a == b then
                tuple (constant a, fuzzer)
                    |> Fuzz.andThen uniquer
            else
                constant (a, b)
    in
        tuple (fuzzer, fuzzer)
            |> Fuzz.andThen uniquer

, fuzzer (, int), . , fuzzed . , .

fuzzer:

fuzz (uniqueTuple int) "All pairs are unique" <|
  \(a, b) ->
      Expect.notEqual a b
+2

Source: https://habr.com/ru/post/1663207/


All Articles