Permalink
Browse files

Exception#== should return true if the two exceptions inherit from Ex…

…ception but have different classes
  • Loading branch information...
1 parent f593fc2 commit 6d27ca1e69394c38fdd8b3aa492ecedaff571619 @atambo committed May 7, 2013
Showing with 4 additions and 4 deletions.
  1. +0 −1 spec/tags/1.9/ruby/core/exception/equal_value_tags.txt
  2. +4 −3 src/org/jruby/RubyException.java
@@ -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);
}

0 comments on commit 6d27ca1

Please sign in to comment.