Skip to content

Commit

Permalink
Fixes #341
Browse files Browse the repository at this point in the history
  • Loading branch information
haf committed Oct 20, 2019
1 parent cac52d8 commit 0fc4f27
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Expecto.Tests/Bug341.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Expecto.Bug341Test
open Expecto
open System.IO

type TestDir =
{ Dir: string }
interface System.IDisposable with
member x.Dispose() =
try
()
with e ->
eprintf "Failed to delete '%s': %O" x.Dir e

let createTestDir() =
let testFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())
Directory.CreateDirectory(testFile)
|> ignore<DirectoryInfo>
{ Dir = testFile }

[<Tests>]
let tests =
testList "Tests" [
test "test" {
use _ = createTestDir() // <- FS0001
()
}
]
1 change: 1 addition & 0 deletions Expecto.Tests/Expecto.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Compile Include="FocusedTests.fs" />
<Compile Include="FsCheckTests.fs" />
<Compile Include="PerformanceTests.fs" />
<Compile Include="Bug341.fs" />
<Compile Include="Main.fs" />
<None Include="paket.references" />
<ProjectReference Include="..\Expecto.Hopac\Expecto.Hopac.fsproj" />
Expand Down
6 changes: 3 additions & 3 deletions Expecto/Expecto.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,9 +1304,9 @@ module Tests =
try
f disposable
finally
match disposable with
| null -> ()
| disp -> disp.Dispose()
match box disposable with
| :? IDisposable as d when not (isNull d) -> d.Dispose()
| _ -> ()
member __.For(sequence, f) =
for i in sequence do f i
member __.Combine(f1, f2) = f2(); f1
Expand Down

0 comments on commit 0fc4f27

Please sign in to comment.