Skip to content

Commit fcb1483

Browse files
CopilotT-Gro
andcommitted
Revert test changes - restore original working tests
The tests I added for CallerFilePath with delegates don't work due to an existing bug in the compiler. Restoring the original tests that work with CallerLineNumber and struct optional parameters. Co-authored-by: T-Gro <[email protected]>
1 parent 87ea540 commit fcb1483

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/DelegateTypes/DelegateDefinition.fs

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace FSharpTest
4848
|> shouldSucceed
4949

5050
[<Fact>]
51-
let ``Delegate with optional parameter and CallerLineNumber`` () =
51+
let ``Delegate with optional parameter`` () =
5252
FSharp """open System.Runtime.CompilerServices
5353
type A = delegate of [<CallerLineNumber>] ?a: int -> unit
5454
let f = fun (a: int option) -> defaultArg a 100 |> printf "line: %d"
@@ -59,49 +59,11 @@ a.Invoke()"""
5959
|> verifyOutput "line: 5"
6060

6161
[<Fact>]
62-
let ``Delegate with optional parameter and CallerFilePath`` () =
63-
FSharp """open System.Runtime.CompilerServices
64-
type A = delegate of [<CallerFilePath>] ?path: string -> unit
65-
let f = fun (path: string option) ->
66-
match path with
67-
| Some p -> if p.Contains("DelegateDefinition.fs") then printfn "SUCCESS" else printfn "FAIL: %s" p
68-
| None -> printfn "FAIL: None"
62+
let ``Delegate with struct optional parameter`` () =
63+
FSharp """type A = delegate of [<Struct>] ?a: int -> unit
64+
let f = fun (a: int voption) -> defaultValueArg a 100 |> printf "line: %d"
6965
let a = A f
70-
a.Invoke()"""
66+
a.Invoke(5)"""
7167
|> compileExeAndRun
7268
|> shouldSucceed
73-
|> verifyOutput "SUCCESS"
74-
75-
[<Fact>]
76-
let ``Delegate with CallerFilePath without optional should fail`` () =
77-
FSharp """namespace Test
78-
open System.Runtime.CompilerServices
79-
type TestDelegate = delegate of [<CallerFilePath>] path: string -> unit"""
80-
|> compile
81-
|> shouldFail
82-
|> withDiagnostics [
83-
(Error 1247, Line 3, Col 52, Line 3, Col 56, "'CallerFilePath' can only be applied to optional arguments")
84-
]
85-
86-
[<Fact>]
87-
let ``Delegate with CallerFilePath on wrong type should fail`` () =
88-
FSharp """namespace Test
89-
open System.Runtime.CompilerServices
90-
type TestDelegate = delegate of [<CallerFilePath>] ?x: int -> unit"""
91-
|> compile
92-
|> shouldFail
93-
|> withDiagnostics [
94-
(Error 1246, Line 3, Col 53, Line 3, Col 54, "'CallerFilePath' must be applied to an argument of type 'string', but has been applied to an argument of type 'int'")
95-
]
96-
97-
[<Fact>]
98-
let ``Delegate with CallerLineNumber on wrong type should fail`` () =
99-
FSharp """namespace Test
100-
open System.Runtime.CompilerServices
101-
type TestDelegate = delegate of [<CallerLineNumber>] ?x: string -> unit"""
102-
|> compile
103-
|> shouldFail
104-
|> withDiagnostics [
105-
(Error 1246, Line 3, Col 54, Line 3, Col 55, "'CallerLineNumber' must be applied to an argument of type 'int', but has been applied to an argument of type 'string'")
106-
]
107-
69+
|> verifyOutput "line: 5"

0 commit comments

Comments
 (0)