Exception#== should return true if the two exceptions inherit from Exception but have different classes #711

Merged
merged 1 commit into from May 7, 2013
@@ -1 +0,0 @@
-fails:Exception#== returns true if the two exceptions inherit from Exception but have different classes
@@ -178,11 +178,12 @@ public IRubyObject inspect(ThreadContext context) {
public IRubyObject op_equal(ThreadContext context, IRubyObject other) {
if (this == other) return context.runtime.getTrue();
- boolean equal =
- getMetaClass().getRealClass() == other.getMetaClass().getRealClass() &&
- context.runtime.getException().isInstance(other) &&
+ boolean equal = context.runtime.getException().isInstance(other) &&
callMethod(context, "message").equals(other.callMethod(context, "message")) &&
callMethod(context, "backtrace").equals(other.callMethod(context, "backtrace"));
+ if (context.runtime.is2_0()) {
+ equal = equal && getMetaClass().getRealClass() == other.getMetaClass().getRealClass();
+ }
return context.runtime.newBoolean(equal);
}