This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #770 from SteveGilham/feature-issue-615-f#-nonpubl…
…ic-types Feature issue 615 f# nonpublic types
- Loading branch information
Showing
6 changed files
with
83 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace N | ||
open NUnit.Framework | ||
module M = | ||
type private Thing = { Thing: string } with | ||
member this.bytes () = System.Text.Encoding.UTF8.GetBytes(this.Thing) | ||
let private makeThing s = { Thing = s } | ||
|
||
[<Test>] | ||
let testMakeThing2() = | ||
Assert.AreEqual("s", (makeThing "s").Thing) | ||
Assert.AreEqual(5, (makeThing "aeiou").bytes().Length) | ||
|
||
module DU = | ||
type private MyUnion = | ||
| Foo of int | ||
| Bar of string | ||
with member this.as_bar() = match this with | ||
| Foo n -> Bar (string n) | ||
| bar -> bar | ||
|
||
let private returnFoo v = Foo v | ||
|
||
let private returnBar v = Bar v | ||
|
||
[<Test>] | ||
let testMakeUnion2() = | ||
Assert.AreEqual(returnFoo 10, Foo 10) | ||
Assert.AreEqual(returnBar "s", Bar "s") | ||
Assert.AreEqual(Bar "10", (Foo 10).as_bar()) |
Binary file not shown.