Skip to content

Commit fbedf0b

Browse files
committed
It was a mistake to treat the key as anything other than a string.
1 parent 07598e7 commit fbedf0b

File tree

1 file changed

+7
-19
lines changed
  • jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie

1 file changed

+7
-19
lines changed

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,21 @@ class VcrSelfie(
7070
disk.writeDisk(snapshot, sub, call)
7171
}
7272
}
73-
fun <K, V> next(
74-
roundtripKey: Roundtrip<K, String>,
75-
key: K,
76-
roundtripValue: Roundtrip<V, String>,
77-
value: Cacheable<V>
78-
): V {
73+
fun <V> next(key: String, roundtripValue: Roundtrip<V, String>, value: Cacheable<V>): V {
7974
if (state.readMode) {
8075
val expected = state.sequence[state.count++]
81-
val keyString = roundtripKey.serialize(key)
82-
if (expected.first != keyString) {
76+
if (expected.first != key) {
8377
throw Selfie.system.fs.assertFailed(
84-
"vcr key mismatch at index ${state.count - 1}", expected, keyString)
78+
"vcr key mismatch at index ${state.count - 1}", expected.first, key)
8579
}
8680
return roundtripValue.parse(expected.second.valueString())
8781
} else {
8882
val value = value.get()
89-
state.sequence.add(
90-
roundtripKey.serialize(key) to SnapshotValue.of(roundtripValue.serialize(value)))
83+
state.sequence.add(key to SnapshotValue.of(roundtripValue.serialize(value)))
9184
return value
9285
}
9386
}
94-
fun next(key: String, value: Cacheable<String>): String =
95-
next(Roundtrip.identity(), key, Roundtrip.identity(), value)
96-
fun <K> next(roundtripKey: Roundtrip<K, String>, key: K, value: Cacheable<String>): String =
97-
next(roundtripKey, key, Roundtrip.identity(), value)
98-
fun <V> next(key: String, roundtripValue: Roundtrip<V, String>, value: Cacheable<V>): V =
99-
next(Roundtrip.identity(), key, roundtripValue, value)
100-
inline fun <reified K, reified V> nextJson(key: K, value: Cacheable<V>): V =
101-
next(RoundtripJson.of<K>(), key, RoundtripJson.of<V>(), value)
87+
fun next(key: String, value: Cacheable<String>): String = next(key, Roundtrip.identity(), value)
88+
inline fun <reified V> nextJson(key: String, value: Cacheable<V>): V =
89+
next(key, RoundtripJson.of<V>(), value)
10290
}

0 commit comments

Comments
 (0)