Skip to content

Commit

Permalink
Merge branch 'main' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vzarytovskii authored Jul 26, 2024
2 parents fca5208 + 15e6c34 commit 83683e1
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 8 deletions.
8 changes: 6 additions & 2 deletions UseLocalCompiler.Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<LoadLocalFSharpBuild Condition="'$(LoadLocalFSharpBuild)' == ''">False</LoadLocalFSharpBuild>

<LocalFSharpCompilerConfiguration Condition="'$(LocalFSharpCompilerConfiguration)' == ''">Release</LocalFSharpCompilerConfiguration>

<LocalFSharpCompilerPath Condition=" '$(LocalFSharpCompilerPath)' == '' ">$(MSBuildThisFileDirectory)</LocalFSharpCompilerPath>
Expand All @@ -12,7 +14,9 @@

<FSharpPreferNetFrameworkTools>False</FSharpPreferNetFrameworkTools>
<FSharpPrefer64BitTools>True</FSharpPrefer64BitTools>
</PropertyGroup>

<PropertyGroup Condition="'$(LoadLocalFSharpBuild)' == 'True'">
<LocalFSharpBuildBinPath>$(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0</LocalFSharpBuildBinPath>
<FSharpBuildAssemblyFile>$(LocalFSharpBuildBinPath)/FSharp.Build.dll</FSharpBuildAssemblyFile>
<FSharpTargetsPath>$(LocalFSharpBuildBinPath)/Microsoft.FSharp.Targets</FSharpTargetsPath>
Expand All @@ -21,8 +25,8 @@
<FSharpOverridesTargetsShim>$(LocalFSharpBuildBinPath)/Microsoft.FSharp.Overrides.NetSdk.targets</FSharpOverridesTargetsShim>
</PropertyGroup>

<UsingTask TaskName="FSharpEmbedResourceText" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />
<UsingTask TaskName="FSharpEmbedResXSource" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />
<UsingTask Condition="'$(LoadLocalFSharpBuild)' == 'True'" TaskName="FSharpEmbedResourceText" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />
<UsingTask Condition="'$(LoadLocalFSharpBuild)' == 'True'" TaskName="FSharpEmbedResXSource" AssemblyFile="$(FSharpBuildAssemblyFile)" Override="true" />

<ItemGroup>
<Reference Include="$(LocalFSharpCompilerPath)/artifacts/bin/FSharp.Core/$(LocalFSharpCompilerConfiguration)/netstandard2.0/FSharp.Core.dll" />
Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.100.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Fixed

* Compiler hangs when compiling inline recursive invocation ([Issue #17376](https://github.com/dotnet/fsharp/issues/17376), [PR #17394](https://github.com/dotnet/fsharp/pull/17394))
* Fix reporting IsFromComputationExpression only for CE builder type constructors and let bindings. ([PR #17375](https://github.com/dotnet/fsharp/pull/17375))

### Added

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Core/9.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Added

* Enable C# collection expression support for F# lists & sets. ([Language suggestion #1355](https://github.com/fsharp/fslang-suggestions/issues/1355), [RFC FS-1145 (PR#776)](https://github.com/fsharp/fslang-design/pull/776), [PR #17359](https://github.com/dotnet/fsharp/pull/17359))
* Add module functions for converting between `'T option` and `'T voption`. ([PR #17436](https://github.com/dotnet/fsharp/pull/17436))

### Changed
* Change compiler default setting realsig+ when building assemblies ([Issue #17384](https://github.com/dotnet/fsharp/issues/17384), [PR #17378](https://github.com/dotnet/fsharp/pull/17385))
Expand Down
7 changes: 7 additions & 0 deletions docs/release-notes/.VisualStudio/17.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Fixed

### Added

### Changed

### Breaking Changes
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckComputationExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ let TcComputationExpression (cenv: cenv) env (overallTy: OverallTy) tpenv (mWhol
// An unparameterized custom builder, e.g., `query`, `async`.
| Expr.Val(vref, _, m)
// A parameterized custom builder, e.g., `builder<…>`, `builder ()`.
| Expr.App(funcExpr = Expr.Val(vref, _, m)) ->
| Expr.App(funcExpr = Expr.Val(vref, _, m)) when not vref.IsMember || vref.IsConstructor ->
let item = Item.CustomBuilder(vref.DisplayName, vref)
CallNameResolutionSink cenv.tcSink (m, env.NameEnv, item, emptyTyparInst, ItemOccurence.Use, env.eAccessRights)
valRefEq cenv.g vref cenv.g.query_value_vref
Expand Down
24 changes: 24 additions & 0 deletions src/FSharp.Core/option.fs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ module Option =
| Some x -> x
#endif

[<CompiledName("OfValueOption")>]
let inline ofValueOption (voption: 'T voption) =
match voption with
| ValueNone -> None
| ValueSome x -> Some x

[<CompiledName("ToValueOption")>]
let inline toValueOption (option: 'T option) =
match option with
| None -> ValueNone
| Some x -> ValueSome x

module ValueOption =

[<CompiledName("GetValue")>]
Expand Down Expand Up @@ -355,3 +367,15 @@ module ValueOption =
| ValueNone -> null
| ValueSome x -> x
#endif

[<CompiledName("OfOption")>]
let inline ofOption (option: 'T option) =
match option with
| None -> ValueNone
| Some x -> ValueSome x

[<CompiledName("ToOption")>]
let inline toOption (voption: 'T voption) =
match voption with
| ValueNone -> None
| ValueSome x -> Some x
60 changes: 60 additions & 0 deletions src/FSharp.Core/option.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,36 @@ module Option =
val inline toObj: value: 'T option -> 'T | null when 'T : not struct (* and 'T : not null *)
#endif

/// <summary>Convert a value option to an option.</summary>
///
/// <param name="voption">The input value option.</param>
///
/// <returns>The resulting option.</returns>
///
/// <example id="ofValueOption-1">
/// <code lang="fsharp">
/// ValueSome 42 |> Option.ofValueOption // evaluates to Some 42
/// (ValueNone: int voption) |> Option.ofValueOption // evaluates to None
/// </code>
/// </example>
[<CompiledName("OfValueOption")>]
val inline ofValueOption: voption: 'T voption -> 'T option

/// <summary>Convert an option to a value option.</summary>
///
/// <param name="option">The input option.</param>
///
/// <returns>The resulting value option.</returns>
///
/// <example id="toValueOption-1">
/// <code lang="fsharp">
/// Some 42 |> Option.toValueOption // evaluates to ValueSome 42
/// (None: int option) |> Option.toValueOption // evaluates to ValueNone
/// </code>
/// </example>
[<CompiledName("ToValueOption")>]
val inline toValueOption: option: 'T option -> 'T voption

/// <summary>Contains operations for working with value options.</summary>
///
/// <category>Options</category>
Expand Down Expand Up @@ -926,3 +956,33 @@ module ValueOption =
// TODO NULLNESS: assess this change - is it a breaking change?
val inline toObj: value: 'T voption -> 'T | null when 'T : not struct (* and 'T : not null *)
#endif

/// <summary>Convert an option to a value option.</summary>
///
/// <param name="option">The input option.</param>
///
/// <returns>The resulting value option.</returns>
///
/// <example id="ofOption-1">
/// <code lang="fsharp">
/// Some 42 |> ValueOption.ofOption // evaluates to ValueSome 42
/// (None: int option) |> ValueOption.ofOption // evaluates to ValueNone
/// </code>
/// </example>
[<CompiledName("OfOption")>]
val inline ofOption: option: 'T option -> 'T voption

/// <summary>Convert a value option to an option.</summary>
///
/// <param name="voption">The input value option.</param>
///
/// <returns>The resulting option.</returns>
///
/// <example id="toOption-1">
/// <code lang="fsharp">
/// ValueSome 42 |> ValueOption.toOption // evaluates to Some 42
/// (ValueNone: int voption) |> ValueOption.toOption // evaluates to None
/// </code>
/// </example>
[<CompiledName("ToOption")>]
val inline toOption: voption: 'T voption -> 'T option
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,20 @@ let _pythags = seqbuilder {{
|> FSharp
|> typecheck
|> shouldSucceed

[<Fact>]
let ``A CE returned from type member succeeds``() =
FSharp """
module ComputationExpressionTests
type Builder () =
member _.Bind(x, f) = f x
member _.Return(x) = x
type A =
static member Prop = Builder ()
let x = A.Prop { return 0 }
"""
|> compile
|> shouldSucceed
|> ignore
50 changes: 45 additions & 5 deletions tests/FSharp.Compiler.Service.Tests/Symbols.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module FSharp.Compiler.Service.Tests.Symbols

open System
open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.Service.Tests.Common
open FSharp.Compiler.Symbols
Expand Down Expand Up @@ -1090,19 +1089,32 @@ let builder = Builder ()
let x = builder { return 3 }
let y = builder
let z = Builder () { return 3 }
type A () =
let builder = Builder ()
let _ = builder { return 3 }
static member Builder = Builder ()
type System.Object with
static member Builder = Builder ()
let c = A.Builder { return 3 }
let d = System.Object.Builder { return 3 }
"""
shouldEqual checkResults.Diagnostics [||]

shouldEqual
[
// type Builder () =
(2, 5), false

// … = Builder ()
(6, 14), false

// let builder = …
(6, 4), false

// … = Builder ()
(6, 14), false

// let x = builder { return 3 }
(8, 8), false // Item.Value _
(8, 8), true // Item.CustomBuilder _
Expand All @@ -1112,9 +1124,37 @@ let z = Builder () { return 3 }

// let z = Builder () { return 3 }
(10, 8), false

// let builder = …
(13, 8), false

// … = Builder ()
(13, 18), false

// let x = builder { return 3 }
(14, 12), false // Item.Value _
(14, 12), true // Item.CustomBuilder _

// static member Builder = …
(16, 18), false

// … = Builder ()
(16, 28), false

// static member Builder = …
(19, 18), false

// … = Builder ()
(19, 28), false

// A.Builder { return 3 }
(21, 8), false

// System.Object.Builder { return 3 }
(22, 8), false
]
[
for symbolUse in checkResults.GetAllUsesOfAllSymbolsInFile() do
for symbolUse in checkResults.GetAllUsesOfAllSymbolsInFile() |> Seq.sortBy (fun x -> x.Range.StartLine, x.Range.StartColumn) do
match symbolUse.Symbol.DisplayName with
| "Builder" | "builder" -> (symbolUse.Range.StartLine, symbolUse.Range.StartColumn), symbolUse.IsFromComputationExpression
| _ -> ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2016,8 +2016,10 @@ Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] Filt
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] Flatten[T](Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[T]])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfNullable[T](System.Nullable`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfObj[T](T)
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfValueOption[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OrElseWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.FSharpOption`1[T]], Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OrElse[T](Microsoft.FSharp.Core.FSharpOption`1[T], Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpValueOption`1[T] ToValueOption[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: System.Nullable`1[T] ToNullable[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: T DefaultValue[T](T, Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: T DefaultWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,T], Microsoft.FSharp.Core.FSharpOption`1[T])
Expand Down Expand Up @@ -2124,6 +2126,7 @@ Microsoft.FSharp.Core.ValueOption: Boolean IsNone[T](Microsoft.FSharp.Core.FShar
Microsoft.FSharp.Core.ValueOption: Boolean IsSome[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Int32 Count[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Collections.FSharpList`1[T] ToList[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpOption`1[T] ToOption[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Bind[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpValueOption`1[TResult]], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Map2[T1,T2,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,TResult]], Microsoft.FSharp.Core.FSharpValueOption`1[T1], Microsoft.FSharp.Core.FSharpValueOption`1[T2])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Map3[T1,T2,T3,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,Microsoft.FSharp.Core.FSharpFunc`2[T3,TResult]]], Microsoft.FSharp.Core.FSharpValueOption`1[T1], Microsoft.FSharp.Core.FSharpValueOption`1[T2], Microsoft.FSharp.Core.FSharpValueOption`1[T3])
Expand All @@ -2132,6 +2135,7 @@ Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T]
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] Flatten[T](Microsoft.FSharp.Core.FSharpValueOption`1[Microsoft.FSharp.Core.FSharpValueOption`1[T]])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfNullable[T](System.Nullable`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfObj[T](T)
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfOption[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OrElseWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.FSharpValueOption`1[T]], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OrElse[T](Microsoft.FSharp.Core.FSharpValueOption`1[T], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: System.Nullable`1[T] ToNullable[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2019,8 +2019,10 @@ Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] Filt
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] Flatten[T](Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Core.FSharpOption`1[T]])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfNullable[T](System.Nullable`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfObj[T](T)
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OfValueOption[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OrElseWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.FSharpOption`1[T]], Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpOption`1[T] OrElse[T](Microsoft.FSharp.Core.FSharpOption`1[T], Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: Microsoft.FSharp.Core.FSharpValueOption`1[T] ToValueOption[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: System.Nullable`1[T] ToNullable[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: T DefaultValue[T](T, Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.OptionModule: T DefaultWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,T], Microsoft.FSharp.Core.FSharpOption`1[T])
Expand Down Expand Up @@ -2127,6 +2129,7 @@ Microsoft.FSharp.Core.ValueOption: Boolean IsNone[T](Microsoft.FSharp.Core.FShar
Microsoft.FSharp.Core.ValueOption: Boolean IsSome[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Int32 Count[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Collections.FSharpList`1[T] ToList[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpOption`1[T] ToOption[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Bind[T,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T,Microsoft.FSharp.Core.FSharpValueOption`1[TResult]], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Map2[T1,T2,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,TResult]], Microsoft.FSharp.Core.FSharpValueOption`1[T1], Microsoft.FSharp.Core.FSharpValueOption`1[T2])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[TResult] Map3[T1,T2,T3,TResult](Microsoft.FSharp.Core.FSharpFunc`2[T1,Microsoft.FSharp.Core.FSharpFunc`2[T2,Microsoft.FSharp.Core.FSharpFunc`2[T3,TResult]]], Microsoft.FSharp.Core.FSharpValueOption`1[T1], Microsoft.FSharp.Core.FSharpValueOption`1[T2], Microsoft.FSharp.Core.FSharpValueOption`1[T3])
Expand All @@ -2135,6 +2138,7 @@ Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T]
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] Flatten[T](Microsoft.FSharp.Core.FSharpValueOption`1[Microsoft.FSharp.Core.FSharpValueOption`1[T]])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfNullable[T](System.Nullable`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfObj[T](T)
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OfOption[T](Microsoft.FSharp.Core.FSharpOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OrElseWith[T](Microsoft.FSharp.Core.FSharpFunc`2[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.FSharpValueOption`1[T]], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: Microsoft.FSharp.Core.FSharpValueOption`1[T] OrElse[T](Microsoft.FSharp.Core.FSharpValueOption`1[T], Microsoft.FSharp.Core.FSharpValueOption`1[T])
Microsoft.FSharp.Core.ValueOption: System.Nullable`1[T] ToNullable[T](Microsoft.FSharp.Core.FSharpValueOption`1[T])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ type OptionModule() =
Assert.True( Option.ofObj<string[]> null = None)
Assert.True( Option.ofObj<int[]> null = None)

[<Fact>]
member this.OfToValueOption() =
Assert.Equal(ValueSome 3, Option.toValueOption (Some 3))
Assert.Equal(ValueNone, Option.toValueOption (None: int option))
Assert.Equal(Some 3, Option.ofValueOption (ValueSome 3))
Assert.Equal(None, Option.ofValueOption (ValueNone: int voption))

[<Fact>]
member this.DefaultValue() =
Assert.AreEqual( Option.defaultValue 3 None, 3)
Expand Down Expand Up @@ -380,6 +387,13 @@ type ValueOptionTests() =
Assert.True(ValueOption.ofObj<string[]> null = ValueNone)
Assert.True(ValueOption.ofObj<int[]> null = ValueNone)

[<Fact>]
member this.OfToOption() =
Assert.Equal(Some 3, ValueOption.toOption (ValueSome 3))
Assert.Equal(None, ValueOption.toOption (ValueNone: int voption))
Assert.Equal(ValueSome 3, ValueOption.ofOption (Some 3))
Assert.Equal(ValueNone, ValueOption.ofOption (None: int option))

[<Fact>]
member this.DefaultValue() =
Assert.AreEqual(ValueOption.defaultValue 3 ValueNone, 3)
Expand Down

0 comments on commit 83683e1

Please sign in to comment.