Created
October 2, 2023 19:40
-
-
Save iamvery/7382aff71a18fe674e818169c11eda99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RandomTest do | |
use ExUnit.Case | |
test "randomness may be seeded" do | |
seed = :rand.export_seed() | |
list = Enum.to_list(1..10_000) | |
values = | |
for _ <- 1..10_000 do | |
Enum.random(list) | |
|> tap(fn _ -> :rand.seed(seed) end) | |
end | |
assert values |> Enum.uniq() |> length == 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment