Skip to content

Commit

Permalink
Recheck's Size overrides Property's Size
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmaturtle committed Apr 10, 2022
1 parent 6229210 commit 716a51b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Hedgehog.Xunit/InternalLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ let report (testMethod:MethodInfo) testClass testClassInstance =
|> ListGen.sequence
let gens =
match size, recheck with
| _ , Some(size, _)
| Some size, _ -> gens |> Gen.resize size
| None , _ -> gens
| _ , Some _ // could pull the size out of the recheckData... but it seems like it isn't necessary? Unable to write failing test.
| None , _ -> gens
| Some size, _ -> gens |> Gen.resize size
let invoke args =
try
( if testMethod.ContainsGenericParameters then
Expand Down
17 changes: 17 additions & 0 deletions tests/Hedgehog.Xunit.Tests/PropertyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,23 @@ module RecheckTests =
| Some actualRecheckData ->
Assert.Equal(expectedRecheckData, actualRecheckData)

[<Recheck("99_99_99_")>]
let [<Property(Size = 1, Skip = skipReason)>] ``Recheck's Size overrides Property's Size, skipped, 99`` (_: int) = ()
[<Recheck("1_1_1_")>]
let [<Property(Size = 99, Skip = skipReason)>] ``Recheck's Size overrides Property's Size, skipped, 1`` (_: int) = ()
[<Fact>]
let ``Recheck's Size overrides Property's Size`` () =
let lastGennedInt test =
let report = InternalLogic.report (test |> getMethod) typeof<Marker>.DeclaringType null
let exn = Assert.Throws<Exception>(fun () -> InternalLogic.tryRaise report)
System.Text.RegularExpressions.Regex.Match(exn.ToString(), "\[-?(\d+)\]").Groups.Item(1).Value |> Int32.Parse

let gennedWithSize99 = nameof ``Recheck's Size overrides Property's Size, skipped, 99`` |> lastGennedInt
gennedWithSize99 > 999_999_999 |> Assert.True

let gennedWithSize1 = nameof ``Recheck's Size overrides Property's Size, skipped, 1`` |> lastGennedInt
gennedWithSize1 < 100 |> Assert.True

[<Properties(Size=1)>]
module SizeTests =
type private Marker = class end
Expand Down

0 comments on commit 716a51b

Please sign in to comment.