This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Richard Feldman
committed
Jul 14, 2017
1 parent
bb46170
commit 5bfcedd
Showing
3 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
module SeedTests exposing (fixedSeed, tests) | ||
|
||
import Expect exposing (FloatingPointTolerance(Absolute, AbsoluteOrRelative, Relative)) | ||
import Fuzz exposing (..) | ||
import Random.Pcg as Random | ||
import Test exposing (..) | ||
|
||
|
||
fixedSeed : Random.Seed | ||
fixedSeed = | ||
Random.initialSeed 133742 | ||
|
||
|
||
expectedNum : Int | ||
expectedNum = | ||
1083264770 | ||
|
||
|
||
{-| Most of the tests will use this, but we won't run it directly. | ||
When these tests are run using fixedSeed and a run count of 1, this is the | ||
exact number they will get when the description around this fuzz test is | ||
exactly the string "Seed test". | ||
-} | ||
fuzzTest : Test | ||
fuzzTest = | ||
fuzz int "It receives the expected number" <| | ||
\num -> | ||
Expect.equal num expectedNum | ||
|
||
|
||
tests : List Test | ||
tests = | ||
[ describe "Seed test" | ||
[ fuzzTest ] | ||
, describe "Seed test" | ||
[ fuzz int "It receives the expected number even though this text is different" <| | ||
\num -> | ||
Expect.equal num expectedNum | ||
] | ||
, describe "Seed test" | ||
[ describe "Nested describes shouldn't affect seed distribution" | ||
[ fuzzTest ] | ||
] | ||
, describe "Seed test" | ||
[ test "Unit tests before should not affect seed distribution" <| | ||
\_ -> | ||
Expect.pass | ||
, fuzzTest | ||
, test "Unit tests after should not affect seed distribution" <| | ||
\_ -> | ||
Expect.pass | ||
] | ||
, -- Wrapping in a Test.concat shouldn't change anything | ||
Test.concat | ||
[ describe "Seed test" | ||
[ fuzzTest ] | ||
] | ||
, -- Wrapping in a Test.concat wth unit tests shouldn't change anything | ||
Test.concat | ||
[ describe "Seed test" | ||
[ test "Unit tests before should not affect seed distribution" <| | ||
\_ -> | ||
Expect.pass | ||
, fuzzTest | ||
, test "Unit tests after should not affect seed distribution" <| | ||
\_ -> | ||
Expect.pass | ||
] | ||
] | ||
] |