dsaff / truth-old

Truth: we've made Failure a Strategy
Apache License 2.0
5 stars 2 forks source link

name of is() #21

Open dsaff opened 13 years ago

dsaff commented 13 years ago

Hamcrest used is() for equality (and overloaded it for isInstanceOf). I think obj == obj is (should be) a rare enough assertion (in situations where it differs from obj.equals(obj)) that it deserves a longer name than obj.equals(obj).

Can we make is() a shorthand for isEqualTo, and make the current is() isTheSameAs(), or some such? I think we should have both longer aliases, anyway, for people who want to be explicit.

cgruber commented 13 years ago

Just to clarify - you're suggesting that we have is() exist, but simply delegate to isEqualTo(), hten make isTheSameAs() or isExactly()?

I'm ok with that, except that the english meaning of "is" is identity, and I don't want to confuse things... but frankly it's all confused already.

I used "isA()" for instanceof, since that's a common O-O phrase.

In principle, I"m ok with this, though I'm tempted to ditch is() altogether as too misleading. I just can't bring myself to lose it as a terse nice word in the phrasing of tests. :(

dsaff commented 13 years ago

Yes, I'm saying that people coming from hamcrest are used to seeing is(), but in hamcrest, is === isEqualTo. I would argue that in Java, it's good practice to thing of .equals as being "real equality", and == as an implementation detail that sometimes accidentally coincides with "real equality"

cgruber commented 13 years ago

I'll buy that.