Skip to content

Instantly share code, notes, and snippets.

@robkuz
Created September 23, 2016 13:32
Show Gist options
  • Save robkuz/d5fe39e7e9ccfb0f73abc00a94aee70c to your computer and use it in GitHub Desktop.
Save robkuz/d5fe39e7e9ccfb0f73abc00a94aee70c to your computer and use it in GitHub Desktop.
Checking if DU Value constructors are "reflected" in the same order of definition
//I'd like to see if the test below is true on different execution environments and compilers
//so if you could please run this code and report back to me at @kuzrob. Thanks
open Microsoft.FSharp.Reflection
type SomeDU<'a,'b, 'c> =
| One of 'a
| Two of 'a * 'b
| Three of 'a * 'b * 'c
[<Test>]
let ``is the order correct?`` () =
let result = FSharpType.GetUnionCases typeof<SomeDU<_,_,_>> |> Array.map (fun case -> case.Name)
printfn "isTrue: %A" ([|"One"; "Two"; "Three"|] = result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment