Skip to content

Commit

Permalink
Upgrade Reggie.Tests to use FsCheck 2.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-pappas committed Nov 1, 2015
1 parent c2bb08c commit 9238426
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Reggie.Tests/Collections.fs
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*)

namespace Tests.FSharpLex.SpecializedCollections
namespace Tests.Reggie.SpecializedCollections

open FSharpLex.SpecializedCollections
open NUnit.Framework
Expand Down
9 changes: 7 additions & 2 deletions Reggie.Tests/Regex.fs
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*)

namespace Tests.FSharpLex
namespace Tests.Reggie

open FSharpLex
open FSharpLex.SpecializedCollections
Expand All @@ -27,7 +27,7 @@ open FsCheck
/// Tests for the Regex type and module.
module RegexTests =
[<Test>]
[<Ignore("This test fails and needs to be fixed; it's ignored for now while FsCheck issues are being worked out.")>]
[<Ignore("This test fails and needs to be fixed; it's ignored for now until I have time to understand why it's failing.")>]
let ``difference of CharSet regex with itself is the null language`` () : unit =
// Create a CharacterSet regex for the low ASCII characters.
let charSetRegex = Regex.CharacterSet (CharSet.ofRange (char 0) (char 127))
Expand All @@ -42,10 +42,15 @@ module RegexTests =

/// Randomized tests for operations on Regex.
[<Ignore("This fixture is ignored for now because the tests cause FsCheck to crash.")>]
[<TestFixture>]
module RegexRandomizedTests =
[<Test(Description = "Checks that the 'simplify' operation is strongly normalizing; \
i.e., once a regex is simplified, it can't be simplified further.")>]
let ``simplify operation is normalizing`` () : unit =
// If the setup fixture hasn't completed, this test won't work correctly.
if not ReggieTestSetupFixture.SetupComplete then
Assert.Ignore "The setup fixture has not finished running."

assertProp "simplify is strongly normalizing" <| fun regex ->
// Simplify the regex.
let simplifiedRegex = Regex.Simplify regex
Expand Down
2 changes: 1 addition & 1 deletion Reggie.Tests/Reggie.Tests.fsproj
Expand Up @@ -63,7 +63,7 @@
<Private>True</Private>
</Reference>
<Reference Include="FsCheck">
<HintPath>..\packages\FsCheck.2.0.6.0\lib\net45\FsCheck.dll</HintPath>
<HintPath>..\packages\FsCheck.2.2.0.0\lib\net45\FsCheck.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
Expand Down
16 changes: 14 additions & 2 deletions Reggie.Tests/TestSetup.fs
Expand Up @@ -16,8 +16,9 @@ limitations under the License.
*)

namespace Tests.FSharpLex.SpecializedCollections
namespace Tests.Reggie

open System.Threading
open FSharpLex.SpecializedCollections
open NUnit.Framework
open FsUnit
Expand Down Expand Up @@ -50,9 +51,20 @@ type CharSetGenerator =
/// generators used by multiple test fixtures.
[<SetUpFixture>]
[<Sealed>]
type FSharpLexTestSetupFixture () =
type ReggieTestSetupFixture () =
/// Indicates when setup has completed.
/// Zero means non-completed; non-zero means completed.
static let mutable setupComplete = 0

/// Indicates when setup has completed.
static member SetupComplete
with get () = setupComplete <> 0

//
[<SetUp>]
member __.SetUp () =
// Register FsCheck generators needed for CharSet tests.
Arb.register<CharSetGenerator> () |> ignore

// Set the flag indicating setup has completed.
Interlocked.Exchange (&setupComplete, 1) |> ignore
2 changes: 1 addition & 1 deletion Reggie.Tests/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExtCore" version="0.8.43" targetFramework="net40" />
<package id="FsCheck" version="2.0.6.0" targetFramework="net45" />
<package id="FsCheck" version="2.2.0.0" targetFramework="net45" />
<package id="FsUnit" version="1.2.1.0" targetFramework="net40" />
<package id="NUnit" version="2.6.4" targetFramework="net40" />
</packages>

0 comments on commit 9238426

Please sign in to comment.