Skip to content

Commit 1ee4009

Browse files
committed
msgSnapshotMismatch() is now piped to strings.
1 parent dfa3c68 commit 1ee4009

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/Mode.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ enum class Mode {
4242
internal fun msgSnapshotNotFound() = msg("Snapshot not found")
4343
internal fun msgSnapshotNotFoundNoSuchFile(file: TypedPath) =
4444
msg("Snapshot not found: no such file $file")
45-
internal fun msgSnapshotMismatch() = msg("Snapshot mismatch")
45+
internal fun msgSnapshotMismatch(expected: String, actual: String) = msg("Snapshot mismatch")
46+
internal fun msgSnapshotMismatchBinary(expected: ByteArray, actual: ByteArray) =
47+
msg("Snapshot mismatch")
4648
private fun msg(headline: String) =
4749
when (this) {
4850
interactive ->

jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/SelfieImplementations.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ class BinarySelfie(actual: Snapshot, disk: DiskStorage, private val onlyFacet: S
146146
return actualBytes
147147
} else {
148148
throw Selfie.system.fs.assertFailed(
149-
Selfie.system.mode.msgSnapshotMismatch(), expected, actualBytes)
149+
Selfie.system.mode.msgSnapshotMismatchBinary(expected, actualBytes),
150+
expected,
151+
actualBytes)
150152
}
151153
}
152154
}
@@ -241,7 +243,9 @@ private fun <T : Any> toBeDidntMatch(expected: T?, actual: T, format: LiteralFor
241243
throw Selfie.system.fs.assertFailed("Can't call `toBe_TODO` in ${Mode.readonly} mode!")
242244
} else {
243245
throw Selfie.system.fs.assertFailed(
244-
Selfie.system.mode.msgSnapshotMismatch(), expected, actual)
246+
Selfie.system.mode.msgSnapshotMismatch(expected.toString(), actual.toString()),
247+
expected,
248+
actual)
245249
}
246250
}
247251
}
@@ -263,10 +267,12 @@ private fun assertEqual(expected: Snapshot?, actual: Snapshot, storage: Snapshot
263267
.filter { expected.subjectOrFacetMaybe(it) != actual.subjectOrFacetMaybe(it) }
264268
.toList()
265269
.sorted()
270+
val expectedFacets = serializeOnlyFacets(expected, mismatchedKeys)
271+
val actualFacets = serializeOnlyFacets(actual, mismatchedKeys)
266272
throw storage.fs.assertFailed(
267-
storage.mode.msgSnapshotMismatch(),
268-
serializeOnlyFacets(expected, mismatchedKeys),
269-
serializeOnlyFacets(actual, mismatchedKeys))
273+
storage.mode.msgSnapshotMismatch(expectedFacets, actualFacets),
274+
expectedFacets,
275+
actualFacets)
270276
}
271277
}
272278
}

0 commit comments

Comments
 (0)