From: <Vin...@ge...> - 2003-06-02 22:38:34
|
> According to the Java equals protocol, the expressions > arg.equals(_object) > and _object.equals(arg) must act the same, so it makes no > difference. If > the two expressions act differently, then that is a bug in the > implementation of the class of arg or _object. Thanks, I know that ;-) But sometimes you have to deal with legacy code that doesn't respect this contract or doesn't even override equals so the other way around makes a *big* difference. It let me override equals in a derived class and use that class as the expected value in a test, so that I can overcome the shortcomings of the legacy code. I can follow your advice and implement my own constraint, but it looks like the same constraint to me. If it makes no difference, is it possible to change IsEqual for the other way around. Unless it leads to other problems I'm not aware of ... The ExpectationValue class do it expected.equals(actual) so it's also make it easier to migrate to the new dynamic mock framework. Any opinion? Thanks, Vincent > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...]On Behalf Of > Nat Pryce > Sent: Monday, June 02, 2003 6:07 PM > To: Vincent Tence; 'Mockobjects-Java-Dev' > Subject: Re: [MO-java-dev] Is IsEqual testing for equality in > the right > order? > > > According to the Java equals protocol, the expressions > arg.equals(_object) > and _object.equals(arg) must act the same, so it makes no > difference. If > the two expressions act differently, then that is a bug in the > implementation of the class of arg or _object. > > Cheers, > Nat. > _______________________ > Dr. Nathaniel Pryce > B13media Ltd. > http://www.b13media.com > +44 (0)7712 526 661 > > ----- Original Message ----- > From: "Vincent Tence" <Vin...@ge...> > To: "'Mockobjects-Java-Dev'" > <moc...@li...> > Sent: Monday, June 02, 2003 10:57 PM > Subject: [MO-java-dev] Is IsEqual testing for equality in the > right order? > > > > Hi, > > > > I noticed that the IsEqual constraint tests for equality by > comparing the > > expected value against the actual value. IIRC it used to be > the other way > > around with "static" mocks - i.e. expected.equals(actual) - > so you could > > deal with legacy code not implementing equals correctly. It > has helped me > in > > a number of situtations. Any reason why this has changed? > > > > Extract from IsEqual : > > > > public boolean eval( Object arg ) { > > if(arg instanceof Object[]) { > > arg = Arrays.asList((Object[])arg); > > } > > return arg.equals(_object); > > } > > > > It could be _object.equals(arg) or am I missing something? > > > > Thanks, > > Vincent > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: eBay > > Get office equipment for less on eBay! > > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > > _______________________________________________ > > Mockobjects-java-dev mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > |