Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
* When `toBe()` snapshots fail in write mode, they now include the expected / actual values, to fill the gap until #49 is finished.

## [0.2.0] - 2023-12-27
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.util.stream.Collectors
import kotlin.io.path.name
import org.opentest4j.AssertionFailedError

/** Represents the line at which user code called into Selfie. */
data class CallLocation(val clazz: String, val method: String, val file: String?, val line: Int) :
Expand Down Expand Up @@ -101,8 +102,10 @@ internal class InlineWriteTracker : WriteTracker<CallLocation, LiteralValue<*>>(
fun record(call: CallStack, literalValue: LiteralValue<*>, layout: SnapshotFileLayout) {
recordInternal(call.location, literalValue, call, layout)
if (literalValue.expected != null) {
throw UnsupportedOperationException(
"`.toBe() didn't match! Change to `toBe_TODO()` to record a new value until https://github.com/diffplug/selfie/pull/49 is merged.")
throw AssertionFailedError(
"`.toBe() didn't match! Change to `toBe_TODO()` to record a new value until https://github.com/diffplug/selfie/pull/49 is merged",
literalValue.expected,
literalValue.actual)
}
}
fun hasWrites(): Boolean = writes.isNotEmpty()
Expand Down