-
Notifications
You must be signed in to change notification settings - Fork 2
primitives, or BoxedPrimitives? #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'd prefer the boxed primitives. It requires more bookkeeping, but I think the job of this framework is to do the bookkeeping so the test writer doesn't have to. The only book-keeping is really around nulls, I think. |
We should resolve this, however, before we implement the float/double side of the house. |
I see both sides of the issue, but here's a presentation of just one side I like the idea of taking primitives because: (1) developer instincts can be better employed. For example, how many developers know that ! (new Integer(3).equals(new Long(3)) or the exact circumstances under which the below happens? (x == y && new Integer(x) != new Integer(y)) Since I'd like to lean on Java's definitions as much as possible, I think the primitive definitions hit closer to what people know better. (2) We can prevent people from ever comparing doubles without a delta. That in and of itself is a huge win. (3) I'm okay with NPEs erupting instantly when someone tries: ASSERT.that((Integer)null).is((Integer)null) (4) I can't figure out a different situation in which auto-deboxing wouldn't Just Work. |
Fair, but I think we can handle ASSERT.that(new Integer(5)).is(new Long(5)) under the hood, by coercing all integral values to the widest type possible before comparison. The same wouldn't be true for inexact floating point stuff, though. Hmm... Ok - would we have BOTH primitives and boxed types then? I think we should, else we end up with ASSERT.that(new Long(5)) would map to TestVerb.that(Object target) which would be bad (see the other thread on that(Object). I think that's the case that beats #4. And I think it points out the problem of #3, bceause I think that would not match the primitives, but that(Object), no? On Jun 13, 2011, at 10:59 AM, dsaff wrote:
|
You're right. We should accept both types, but we should enforce David On Mon, Jun 13, 2011 at 2:08 PM, cgruber
|
Ok. I'm still uncomfortable with the NPE case, but I'm willing to live with it, as long as it's really documented. But then, I'm uncomfortable with null-handling in Java in general. Christian. On Jun 13, 2011, at 12:34 PM, dsaff wrote:
|
Essentially, should IntSubject take an Integer, or an int, in its constructor? Integer is more general, but requires more book-keeping. The conversation continues...
The text was updated successfully, but these errors were encountered: