One thing I miss about the now-deprecated `shouldB...
# kotest
b
One thing I miss about the now-deprecated
shouldBeInstanceOf
that took a block was that I ended up doing things like this:
Copy code
someList.first().shouldBeInstanceOf<Foo> {
  // 'it' is cast to 'Foo'
  it.someMethodOnFoo() shouldBe ...
}
whereas now I end up doing something like
Copy code
with (someList.first()) {
    shouldBeInstanceOf<Foo>()
    someMethodOnFoo() shouldBe ...
}
and I prefer the first style, but perhaps just a personal preference.
s
Copy code
shouldBeInstanceOf
should smart cast
b
I don't think contracts are smart enough to smart cast an element from a list though
s
you could do .apply{} on it maybe
b
Yeah I thought about that but it's not too different from the
with
.
j
and
shouldBeTypeOf()
doesn't smart cast too?
b
Which, of course, isn't a huge difference from the new style, but, I still think I like the old way.