You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BshMethod.equals() succeeds when comparing subclasses with BshMethod instances:
{{{
@SuppressWarnings("serial")
@Test
public void testEqualsObject_subclassEquality() {
// define a simple subclass of BshMethod:
class SubMethod extends BshMethod {
public SubMethod(String name, Class returnType, String[] paramNames,
Class[] paramTypes, BSHBlock methodBody,
NameSpace declaringNameSpace, Modifiers modifiers) {
super(name, returnType, paramNames, paramTypes, methodBody,
declaringNameSpace,
modifiers);
}
};
final String name = "testMethod";
final BshMethod subInst = new SubMethod(name,
Integer.class, new String[]{}, new Class[]{}, null, null, null);
final BshMethod supInst = new BshMethod(name,
Integer.class, new String[]{}, new Class[]{}, null, null, null);
Assert.assertFalse("Subclasses should not be equal to super classes",
supInst.equals(subInst));
}
}}}
This method also does not support the hashcode/equals contract:
{{{
@Test
public void testHashCode_contract() {
final String name = "testMethod";
final BshMethod method1 = new BshMethod(name,
Integer.class, new String[]{}, new Class[]{}, null, null, null);
final BshMethod method2 = new BshMethod(name,
Integer.class, new String[]{}, new Class[]{}, null, null, null);
Assert.assertTrue("precondition check for test failed.",
method2.equals(method1));
Assert.assertEquals("Equal classes should have equal hashcodes",
method2.hashCode(), method1.hashCode());
}
}}}
This is a fairly easy fix, as long as it is not intentional. I'll try and
attach a patch tonight / tomorrow.
Original issue reported on code.google.com by cresw...@gmail.com on 1 Mar 2009 at 12:30
The text was updated successfully, but these errors were encountered:
These tests are now in svn, see revision r35. They are ignored, however, since
they
are known to fail.
I'll check in the fixes to BshMethod as soon as I find time to hack out
`hashCode()`
Original comment by cresw...@gmail.com on 4 Mar 2009 at 3:36
Original issue reported on code.google.com by
cresw...@gmail.com
on 1 Mar 2009 at 12:30The text was updated successfully, but these errors were encountered: