+ @Test
+ fun `onNull is executed on null`() {
+ val called = CountDownLatch(1)
+ null.onNull { called.countDown() }
+ assertThat(called.count, equalTo(0L))
+ }
+
+ @Test
+ fun `onNull returns null when called on null`() {
+ assertThat(null.onNull {}, nullValue())
+ }
+
+ @Test
+ fun `onNull is not executed on non-null`() {
+ val called = CountDownLatch(1)
+ Any().onNull { called.countDown() }
+ assertThat(called.count, equalTo(1L))
+ }
+
+ @Test
+ fun `onNull returns object when called on non-null`() {
+ val any = Any()
+ assertThat(any.onNull {}, sameInstance(any))
+ }
+