-
Notifications
You must be signed in to change notification settings - Fork 842
WIP: Add tests for issue #19074 - voption with optional parameter syntax (?x=) #19076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
adc71bb
9d36fda
86a2cf0
dd44d9a
b1a7969
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,3 +163,86 @@ Test.OverloadedMethodTakingNullableOptionals(x = 6) |> ignore | |
| let fs = Compilation.Create(fsSrc, CompileOutput.Exe, options = [| $"--langversion:{langVersion}" |], cmplRefs = [cs]) | ||
| CompilerAssert.Compile fs | ||
|
|
||
| // Tests for issue #19074: Support voption with optional parameter syntax (?x=) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...Why is it even putting tests in this file at all? This file is about interop with parameters marked with
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It had a somewhat correct start when initially chatting, but then completely derailed. |
||
| [<Fact>] | ||
| let ``F# method with voption optional parameter should accept ValueNone with question mark syntax`` () = | ||
| let fsSrc = | ||
| """ | ||
| open System.Runtime.InteropServices | ||
|
|
||
| type MyClass() = | ||
| member _.Foo([<Optional>] x: int voption) = | ||
| match x with | ||
| | ValueNone -> "none" | ||
| | ValueSome v -> string v | ||
|
|
||
| let c = MyClass() | ||
| let r1 = c.Foo(?x=ValueNone) | ||
| printfn "%s" r1 | ||
| """ | ||
|
|
||
| let fs = Compilation.Create(fsSrc, CompileOutput.Exe, options = [| "--langversion:preview" |]) | ||
| CompilerAssert.Compile fs | ||
|
|
||
| [<Fact>] | ||
| let ``F# method with voption optional parameter should accept ValueSome with question mark syntax`` () = | ||
| let fsSrc = | ||
| """ | ||
| open System.Runtime.InteropServices | ||
|
|
||
| type MyClass() = | ||
| member _.Foo([<Optional>] x: int voption) = | ||
| match x with | ||
| | ValueNone -> "none" | ||
| | ValueSome v -> string v | ||
|
|
||
| let c = MyClass() | ||
| let r2 = c.Foo(?x=ValueSome 42) | ||
| printfn "%s" r2 | ||
| """ | ||
|
|
||
| let fs = Compilation.Create(fsSrc, CompileOutput.Exe, options = [| "--langversion:preview" |]) | ||
| CompilerAssert.Compile fs | ||
|
|
||
| [<Fact>] | ||
| let ``F# method with voption optional parameter should work without question mark syntax`` () = | ||
| let fsSrc = | ||
| """ | ||
| open System.Runtime.InteropServices | ||
|
|
||
| type MyClass() = | ||
| member _.Foo([<Optional>] x: int voption) = | ||
| match x with | ||
| | ValueNone -> "none" | ||
| | ValueSome v -> string v | ||
|
|
||
| let c = MyClass() | ||
| let r1 = c.Foo(x=ValueNone) | ||
| let r2 = c.Foo(x=ValueSome 42) | ||
| printfn "%s %s" r1 r2 | ||
| """ | ||
|
|
||
| let fs = Compilation.Create(fsSrc, CompileOutput.Exe, options = [| "--langversion:preview" |]) | ||
| CompilerAssert.Compile fs | ||
|
|
||
| [<Fact>] | ||
| let ``F# method with option optional parameter should still work with question mark syntax`` () = | ||
| let fsSrc = | ||
| """ | ||
| open System.Runtime.InteropServices | ||
|
|
||
| type MyClass() = | ||
| member _.Foo([<Optional>] x: int option) = | ||
| match x with | ||
| | None -> "none" | ||
| | Some v -> string v | ||
|
|
||
| let c = MyClass() | ||
| let r1 = c.Foo(?x=None) | ||
| let r2 = c.Foo(?x=Some 42) | ||
| printfn "%s %s" r1 r2 | ||
| """ | ||
|
|
||
| let fs = Compilation.Create(fsSrc, CompileOutput.Exe, options = [| "--langversion:preview" |]) | ||
| CompilerAssert.Compile fs | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.