Skip to content

Instantly share code, notes, and snippets.

@pblasucci
Last active October 7, 2022 13:04
Show Gist options
  • Save pblasucci/7c864a98b61cad9190ae84903e99e546 to your computer and use it in GitHub Desktop.
Save pblasucci/7c864a98b61cad9190ae84903e99e546 to your computer and use it in GitHub Desktop.
Using signature files and script files to test private functionality
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library.fsi" />
<Compile Include="Library.fs" />
<Compile Include="Program.fs" />
<None Include="Test.fsx" />
</ItemGroup>
</Project>
namespace Gisty
type NewMaths =
static member ``add it up!``(left, right) = left + right
[<RequireQualifiedAccess>]
module Mathy =
open type NewMaths
let add one two = ``add it up!``(one, two)
namespace Gisty
(**
Anything defined in `Library.fs` -- but not also defined in this file -- will not be exposed to others.
*)
[<RequireQualifiedAccess>]
module Mathy =
/// A novel contribution to the production of sums of natural numbers.
val add : one : int -> two : int -> int
module Gisty.Program
open Gisty
printfn $"2 + 3 = %i{Mathy.add 2 3}"
#r "nuget: FsCheck"
open FsCheck
(* uncomment ⮟⮟⮟ the signature file to emulate the compiled assembly *)
#load (*"Library.fsi"*) "Library.fs"
open Gisty
open type NewMaths
let test one two =
``add it up!``(one, two) = ``add it up!``(two, one)
do Check.Quick(test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment