Hi guys, what do you think about this, it should f...
# kotest
w
Hi guys, what do you think about this, it should fail right?
Copy code
listOf<Int>(1) shouldBe listOf<Int>()
s
Yes it should
w
I think it’s a bug, cuz it’s not failing in my test
Copy code
@Suppress("UNCHECKED_CAST")
infix fun <T, U : T> T.shouldBe(expected: U?) {
   when (expected) {
      is Matcher<*> -> should(expected as Matcher<T>)
      else -> {
         val actual = this
         assertionCounter.inc()
         eq(actual, expected)?.let(errorCollector::collectOrThrow)
      }
   }
}
when
shouldBe
gets a null back it doesn’t throw
Copy code
private fun checkIterableEquality(actual: Iterable<*>, expected: Iterable<*>): Throwable? {
   var index = 0
   actual.zip(expected) { a, b ->
      val t = eq(a, b)
      if (t != null) return failure(
         Expected(expected.show()),
         Actual(actual.show()),
         "Elements differ at index $index: "
      )
      index++
   }
   return null
}
Copy code
public inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {
    val first = iterator()
    val second = other.iterator()
    val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))
    while (first.hasNext() && second.hasNext()) {
        list.add(transform(first.next(), second.next()))
    }
    return list
}
s