wasyl
05/10/2021, 11:16 AM5 shouldBe "5". There’s no error shown, even though the signature would force the right-hand parameter to be a assignable to the left-hand one (infix fun <T, U : T> T.shouldBe(expected: U?)), or so I thought. Is this expected?
It’s pretty annoying when refactoring code, because tests still compile but fail in runtimewasyl
05/10/2021, 11:18 AMwasyl
05/10/2021, 11:20 AMAny.shouldBe(other: Any)?Javier
05/10/2021, 11:22 AMwasyl
05/10/2021, 11:25 AMfoo shouldBe fooSubtype? But even with single generic parameter it seems A() shouldBe C() (no inheritance) works, because now T is just Any as wellwasyl
05/10/2021, 11:28 AMinfix fun Any.shouldBe(expected: Any?): Nothing = error("Unsupported")
but it only works for shouldBe, I’d have to have overloads for all the different matchers 😕sam
05/10/2021, 11:38 AMwasyl
05/10/2021, 11:44 AMT and U would be Any?Javier
05/10/2021, 11:49 AMJavier
05/10/2021, 11:49 AMshouldBeTypeOf I thinkwasyl
05/10/2021, 11:51 AMdoSomething() shouldBe 5. Later on I change doSomething to return a string instead of an int. Normally it’s easy to find all the places to update by just trying to compile the project and navigating to each errorwasyl
05/10/2021, 11:51 AMshouldBe will not result in an error. I still want to do some meaningful change, in this case check that doSomething shouldBe "5", not just check a typewasyl
05/10/2021, 11:53 AM// foo: Any
// bar: Any
foo shouldBe bar
I don’t want shouldBe to resolve generic parameters to Anysam
05/10/2021, 11:53 AMsam
05/10/2021, 11:53 AMsam
05/10/2021, 11:54 AMwasyl
05/10/2021, 11:55 AMAny. And I agree it’s not easy, other than overloading each matcher with a deprecated Any. variant I don’t have a clue what can be donewasyl
05/10/2021, 11:55 AMsam
05/10/2021, 11:57 AMsam
05/10/2021, 11:57 AMJavier
05/10/2021, 11:58 AMshouldBe should not compile if the type is different, and maybe a relaxedShouldBe or something so should be addedwasyl
05/10/2021, 11:59 AMOnlyInputTypes might be helpful, although I don’t have it handy to check how it works exactly. But I see it in kotlin-test sourcessam
05/10/2021, 12:00 PMsam
05/10/2021, 12:01 PMwasyl
05/10/2021, 12:01 PMinternalsam
05/10/2021, 12:02 PMsam
05/10/2021, 12:02 PMsam
05/10/2021, 12:02 PMwasyl
05/10/2021, 12:03 PMshouldBe is symmetricwasyl
05/10/2021, 12:03 PMsam
05/10/2021, 12:03 PMsam
05/10/2021, 12:03 PMsam
05/10/2021, 12:03 PMwasyl
05/10/2021, 12:05 PMshouldBe only true when both sides are exactly the same type?Javier
05/10/2021, 12:05 PManimal shouldBe dog not compilingJavier
05/10/2021, 12:05 PMsam
05/10/2021, 12:05 PMsam
05/10/2021, 12:06 PMsam
05/10/2021, 12:06 PMJavier
05/10/2021, 12:06 PMJavier
05/10/2021, 12:07 PMsam
05/10/2021, 12:07 PMJavier
05/10/2021, 12:07 PMsam
05/10/2021, 12:08 PMsam
05/10/2021, 12:10 PMJavier
05/10/2021, 12:11 PMsam
05/10/2021, 12:11 PMsam
05/10/2021, 12:11 PMsam
05/10/2021, 12:11 PMshouldEqual would be trivial to implement and easy to do a find replace to update existing usages for @wasylJavier
05/10/2021, 12:12 PMmyCat shouldBe black is String shouldBe CharSeqJavier
05/10/2021, 12:12 PMmyCat knows what is color (inherence, property, or whatever), black is a color, it knows nothing about animals or catsJavier
05/10/2021, 12:12 PMsam
05/10/2021, 12:13 PMsam
05/10/2021, 12:13 PMJavier
05/10/2021, 12:13 PMsam
05/10/2021, 12:13 PMwasyl
05/10/2021, 12:14 PMAny.shouldBe in a separate, opt-in artifact?sam
05/10/2021, 12:14 PMJavier
05/10/2021, 12:14 PMJavier
05/10/2021, 12:14 PMsam
05/10/2021, 12:15 PMJavier
05/10/2021, 12:15 PMwasyl
05/10/2021, 12:15 PMaListOfFoo shouldContain bar should fail as wellsam
05/10/2021, 12:16 PM