Skip to content

Commit 649fbe9

Browse files
Restore isSameAs/isNotSameAs extension functions to AssertKExtensions.kt
These custom extensions were incorrectly removed in commit 3d649d9, causing compilation errors in DefaultContextTest.kt and XMLContextFactoryTest.kt. AssertK 0.28.1 does not provide isSameAs()/isNotSameAs() methods - these were custom extensions for checking object identity (===) that are still needed by the test suite. Co-authored-by: bedaHovorka <bedaHovorka@users.noreply.github.com>
1 parent 7180ce2 commit 649fbe9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/test/kotlin/cz/vutbr/fit/interlockSim/testutil/AssertKExtensions.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,30 @@ fun <T> Assert<Collection<T>>.containsAnyOf(vararg elements: T) = given { actual
101101
expected("to contain any of:${show(elements.toList())} but was:${show(actual)}")
102102
}
103103

104+
/**
105+
* Extension function to assert that two objects are the same instance.
106+
*
107+
* Usage: assertThat(obj1).isSameAs(obj2)
108+
*/
109+
fun <T> Assert<T>.isSameAs(expected: T): Assert<T> = apply {
110+
given { actual ->
111+
if (actual === expected) return@given
112+
expected("to be the same instance as:${show(expected)} but was:${show(actual)}")
113+
}
114+
}
115+
116+
/**
117+
* Extension function to assert that two objects are not the same instance.
118+
*
119+
* Usage: assertThat(obj1).isNotSameAs(obj2)
120+
*/
121+
fun <T> Assert<T>.isNotSameAs(expected: T): Assert<T> = apply {
122+
given { actual ->
123+
if (actual !== expected) return@given
124+
expected("to not be the same instance as:${show(expected)}")
125+
}
126+
}
127+
104128
/**
105129
* Extension function to assert that a block of code executes without throwing an exception.
106130
*

0 commit comments

Comments
 (0)