Skip to content

Commit e54cb12

Browse files
committed
more tests
1 parent 5eb3102 commit e54cb12

File tree

5 files changed

+81
-16
lines changed

5 files changed

+81
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #DeclarationElements #LetBindings
2+
//<Expects status="success"></Expects>
3+
open System
4+
5+
let answer =
6+
use x:IDisposable = new System.IO.MemoryStream()
7+
42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
open System
2+
3+
type private Disposable() =
4+
[<DefaultValue>] static val mutable private disposedTimes: int
5+
[<DefaultValue>] static val mutable private constructedTimes: int
6+
7+
do Disposable.constructedTimes <- Disposable.constructedTimes + 1
8+
9+
static member DisposeCallCount() = Disposable.disposedTimes
10+
static member ConstructorCallCount() = Disposable.constructedTimes
11+
12+
interface System.IDisposable with
13+
member _.Dispose() =
14+
Disposable.disposedTimes <- Disposable.disposedTimes + 1
15+
16+
let _scope =
17+
use x: IDisposable = new Disposable()
18+
()
19+
20+
let disposeCalls = Disposable.DisposeCallCount()
21+
if disposeCalls <> 1 then
22+
failwith "was not disposed or disposed too many times"
23+
24+
let ctorCalls = Disposable.ConstructorCallCount()
25+
if ctorCalls <> 1 then
26+
failwithf "unexpected constructor call count: %i" ctorCalls
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
open System
2+
3+
type private Disposable() =
4+
[<DefaultValue>] static val mutable private disposedTimes: int
5+
[<DefaultValue>] static val mutable private constructedTimes: int
6+
7+
do Disposable.constructedTimes <- Disposable.constructedTimes + 1
8+
9+
static member DisposeCallCount() = Disposable.disposedTimes
10+
static member ConstructorCallCount() = Disposable.constructedTimes
11+
12+
interface System.IDisposable with
13+
member _.Dispose() =
14+
Disposable.disposedTimes <- Disposable.disposedTimes + 1
15+
16+
let _scope =
17+
use _:IDisposable = new Disposable()
18+
()
19+
20+
let disposeCalls = Disposable.DisposeCallCount()
21+
if disposeCalls <> 1 then
22+
failwith "was not disposed or disposed too many times"
23+
24+
let ctorCalls = Disposable.ConstructorCallCount()
25+
if ctorCalls <> 1 then
26+
failwithf "unexpected constructor call count: %i" ctorCalls

tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/UseBindings/UseBindings.fs

+22-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,25 @@ module UseBindings =
3333
|> asExe
3434
|> withLangVersion60
3535
|> compileAndRun
36-
|> shouldSucceed
36+
|> shouldSucceed
37+
38+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"UseBindingDiscard03.fs"|])>]
39+
let ``UseBindings - UseBindingDiscard03_fs - Current LangVersion`` compilation =
40+
compilation
41+
|> asExe
42+
|> compileAndRun
43+
|> shouldSucceed
44+
45+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"UseBinding01.fs"|])>]
46+
let ``UseBindings - UseBinding01_fs - Current LangVersion`` compilation =
47+
compilation
48+
|> asFsx
49+
|> compile
50+
|> shouldSucceed
51+
52+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"UseBinding02.fs"|])>]
53+
let ``UseBindings - UseBinding02_fs - Current LangVersion`` compilation =
54+
compilation
55+
|> asFsx
56+
|> compile
57+
|> shouldSucceed

tests/FSharp.Compiler.ComponentTests/Language/ComputationExpressionTests.fs

-15
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ let x = lb {1; 2;}
2222
|> compile
2323
|> shouldSucceed
2424
|> ignore
25-
26-
[<Fact>]
27-
let ``Allow let! and use! binding with type annotation without parentheses.``() =
28-
FSharp """
29-
module ComputationExpressionTests
30-
let f =
31-
async {
32-
let! (a: int) = async { return 1 }
33-
let! b: int = async { return 1 }
34-
return a
35-
}
36-
"""
37-
|> typecheck
38-
|> shouldSucceed
39-
|> ignore
4025

4126
[<Fact>]
4227
let ``A CE explicitly using Zero fails without a defined Zero``() =

0 commit comments

Comments
 (0)