diff --git a/WoofWare.Expect/Library.fs b/WoofWare.Expect/Library.fs
index 58641f3..2bfc555 100644
--- a/WoofWare.Expect/Library.fs
+++ b/WoofWare.Expect/Library.fs
@@ -15,6 +15,10 @@ type private SnapshotValue =
| BareString of string
| Json of string
+/// A dummy type which is here to provide better error messages when you supply
+/// the `snapshot` keyword multiple times.
+type YouHaveSuppliedMultipleSnapshots = private | NonConstructible
+
/// The state accumulated by the `expect` builder. You should never find yourself interacting with this type.
type ExpectState<'T> =
private
@@ -35,7 +39,10 @@ module private Text =
/// Override the file path and line numbers reported in snapshots, so that your tests can be fully stable even on failure. (You almost certainly don't want to set this.)
type ExpectBuilder (?sourceOverride : string * int) =
/// Combine two `ExpectState`s. The first one is the "expected" snapshot; the second is the "actual".
- member _.Bind (state : ExpectState, f : unit -> ExpectState<'U>) : ExpectState<'U> =
+ member _.Bind
+ (state : ExpectState, f : unit -> ExpectState<'U>)
+ : ExpectState<'U>
+ =
let actual = f ()
match state.Actual with
@@ -56,13 +63,13 @@ type ExpectBuilder (?sourceOverride : string * int) =
[]
member _.Snapshot
(
- state : ExpectState<'a>,
+ state : ExpectState,
snapshot : string,
[] ?memberName : string,
[] ?callerLine : int,
[] ?filePath : string
)
- : ExpectState<'a>
+ : ExpectState
=
match state.Snapshot with
| Some _ -> failwith "snapshot can only be specified once"
@@ -78,8 +85,9 @@ type ExpectBuilder (?sourceOverride : string * int) =
LineNumber = lineNumber
}
- { state with
+ {
Snapshot = Some (SnapshotValue.BareString snapshot, callerInfo)
+ Actual = None
}
///
@@ -92,13 +100,13 @@ type ExpectBuilder (?sourceOverride : string * int) =
[]
member _.SnapshotJson
(
- state : ExpectState<'a>,
+ state : ExpectState,
snapshot : string,
[] ?memberName : string,
[] ?callerLine : int,
[] ?filePath : string
)
- : ExpectState<'a>
+ : ExpectState
=
match state.Snapshot with
| Some _ -> failwith "snapshot can only be specified once"
@@ -114,8 +122,9 @@ type ExpectBuilder (?sourceOverride : string * int) =
LineNumber = lineNumber
}
- { state with
+ {
Snapshot = Some (SnapshotValue.Json snapshot, callerInfo)
+ Actual = None
}
/// MaintainsVariableSpaceUsingBind causes this to be used; it's a dummy representing "no snapshot and no assertion".
diff --git a/WoofWare.Expect/SurfaceBaseline.txt b/WoofWare.Expect/SurfaceBaseline.txt
index 06fe417..5d8e006 100644
--- a/WoofWare.Expect/SurfaceBaseline.txt
+++ b/WoofWare.Expect/SurfaceBaseline.txt
@@ -4,12 +4,14 @@ WoofWare.Expect.Builder.expectWithMockedFilePath [static method]: (string, int)
WoofWare.Expect.Builder.get_expect [static method]: unit -> WoofWare.Expect.ExpectBuilder
WoofWare.Expect.ExpectBuilder inherit obj
WoofWare.Expect.ExpectBuilder..ctor [constructor]: (string * int) option
-WoofWare.Expect.ExpectBuilder.Bind [method]: (unit WoofWare.Expect.ExpectState, unit -> 'U WoofWare.Expect.ExpectState) -> 'U WoofWare.Expect.ExpectState
+WoofWare.Expect.ExpectBuilder.Bind [method]: (WoofWare.Expect.YouHaveSuppliedMultipleSnapshots WoofWare.Expect.ExpectState, unit -> 'U WoofWare.Expect.ExpectState) -> 'U WoofWare.Expect.ExpectState
WoofWare.Expect.ExpectBuilder.Delay [method]: (unit -> 'T WoofWare.Expect.ExpectState) -> (unit -> 'T WoofWare.Expect.ExpectState)
WoofWare.Expect.ExpectBuilder.Return [method]: 'T -> 'T WoofWare.Expect.ExpectState
WoofWare.Expect.ExpectBuilder.Return [method]: unit -> 'T WoofWare.Expect.ExpectState
WoofWare.Expect.ExpectBuilder.Run [method]: (unit -> 'T WoofWare.Expect.ExpectState) -> unit
-WoofWare.Expect.ExpectBuilder.Snapshot [method]: ('a WoofWare.Expect.ExpectState, string, string option, int option, string option) -> 'a WoofWare.Expect.ExpectState
-WoofWare.Expect.ExpectBuilder.SnapshotJson [method]: ('a WoofWare.Expect.ExpectState, string, string option, int option, string option) -> 'a WoofWare.Expect.ExpectState
+WoofWare.Expect.ExpectBuilder.Snapshot [method]: (unit WoofWare.Expect.ExpectState, string, string option, int option, string option) -> WoofWare.Expect.YouHaveSuppliedMultipleSnapshots WoofWare.Expect.ExpectState
+WoofWare.Expect.ExpectBuilder.SnapshotJson [method]: (unit WoofWare.Expect.ExpectState, string, string option, int option, string option) -> WoofWare.Expect.YouHaveSuppliedMultipleSnapshots WoofWare.Expect.ExpectState
WoofWare.Expect.ExpectState`1 inherit obj, implements 'T WoofWare.Expect.ExpectState System.IEquatable, System.Collections.IStructuralEquatable, 'T WoofWare.Expect.ExpectState System.IComparable, System.IComparable, System.Collections.IStructuralComparable
-WoofWare.Expect.ExpectState`1.Equals [method]: ('T WoofWare.Expect.ExpectState, System.Collections.IEqualityComparer) -> bool
\ No newline at end of file
+WoofWare.Expect.ExpectState`1.Equals [method]: ('T WoofWare.Expect.ExpectState, System.Collections.IEqualityComparer) -> bool
+WoofWare.Expect.YouHaveSuppliedMultipleSnapshots inherit obj, implements WoofWare.Expect.YouHaveSuppliedMultipleSnapshots System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Expect.YouHaveSuppliedMultipleSnapshots System.IComparable, System.IComparable, System.Collections.IStructuralComparable
+WoofWare.Expect.YouHaveSuppliedMultipleSnapshots.Equals [method]: (WoofWare.Expect.YouHaveSuppliedMultipleSnapshots, System.Collections.IEqualityComparer) -> bool
\ No newline at end of file