@@ -47,14 +47,15 @@ enum class Mode {
4747 msg(" Snapshot " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual))
4848 internal fun msgSnapshotMismatchBinary (expected : ByteArray , actual : ByteArray ) =
4949 msgSnapshotMismatch(expected.toQuotedPrintable(), actual.toQuotedPrintable())
50- internal fun msgVcrSnapshotNotFound () = msg(" VCR snapshot not found" )
51- internal fun msgVcrMismatch (key : String , expected : String , actual : String ) =
52- msg(" VCR frame $key " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual))
53- internal fun msgVcrUnread (expected : Int , actual : Int ) =
54- msg(" VCR frames unread - only $actual were read out of $expected " )
55- internal fun msgVcrUnderflow (expected : Int ) =
56- msg(
57- " VCR frames exhausted - only $expected are available but you tried to read ${expected + 1 } " )
50+ internal fun msgVcrSnapshotNotFound (call : CallStack ) = msgVcr(" VCR snapshot not found" , call)
51+ internal fun msgVcrMismatch (key : String , expected : String , actual : String , call : CallStack ) =
52+ msgVcr(" VCR frame $key " + SnapshotNotEqualErrorMsg .forUnequalStrings(expected, actual), call)
53+ internal fun msgVcrUnread (expected : Int , actual : Int , call : CallStack ) =
54+ msgVcr(" VCR frames unread - only $actual were read out of $expected " , call)
55+ internal fun msgVcrUnderflow (expected : Int , call : CallStack ) =
56+ msgVcr(
57+ " VCR frames exhausted - only $expected are available but you tried to read ${expected + 1 } " ,
58+ call)
5859 private fun ByteArray.toQuotedPrintable (): String {
5960 val sb = StringBuilder ()
6061 for (byte in this ) {
@@ -71,12 +72,18 @@ enum class Mode {
7172 when (this ) {
7273 interactive ->
7374 " $headline \n " +
74- (if (headline.startsWith(" Snapshot " ))
75- " ‣ update this snapshot by adding `_TODO` to the function name\n " +
76- " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`"
77- else
78- " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`\n " +
79- " ‣ if that doesn't work remember to put your test rule into the `selfie` package" )
75+ " ‣ update this snapshot by adding `_TODO` to the function name\n " +
76+ " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`"
77+ readonly -> headline
78+ overwrite -> " $headline \n (didn't expect this to ever happen in overwrite mode)"
79+ }
80+ private fun msgVcr (headline : String , call : CallStack ) =
81+ when (this ) {
82+ interactive ->
83+ " $headline \n " +
84+ " ‣ update all snapshots in this file by adding `//selfieonce` or `//SELFIEWRITE`\n " +
85+ " ‣ could not find control comment in ${call.location.ideLink(Selfie .system.layout)} \n " +
86+ " ‣ remember to call `Selfie.vcrTestLocator()` in the test itself, or put the file above into the `selfie` package to mark that it is not the test file"
8087 readonly -> headline
8188 overwrite -> " $headline \n (didn't expect this to ever happen in overwrite mode)"
8289 }
0 commit comments