Permalink
Browse files

down to 14 failures, 3 errors for test_regexp

  • Loading branch information...
1 parent 1194aa9 commit 8d82e2e9a6323dd0fd557317ee53588599b65831 @lopex lopex committed Feb 16, 2012
Showing with 20 additions and 4 deletions.
  1. +14 −3 src/org/jruby/RubyMatchData.java
  2. +6 −1 src/org/jruby/RubyRegexp.java
View
17 src/org/jruby/RubyMatchData.java
@@ -632,9 +632,11 @@ public IRubyObject string() {
@Override
public IRubyObject initialize_copy(IRubyObject original) {
if (this == original) return this;
-
- if (!(getMetaClass() == original.getMetaClass())){ // MRI also does a pointer comparison here
- throw getRuntime().newTypeError("wrong argument class");
+
+ Ruby runtime = getRuntime();
+ ThreadContext context = runtime.getCurrentContext();
+ if ((original instanceof RubyBasicObject) && !((RubyBasicObject)original).instance_of_p(context, getMetaClass()).isTrue()) {
+ throw runtime.newTypeError("wrong argument class");
}
RubyMatchData origMatchData = (RubyMatchData)original;
@@ -645,6 +647,7 @@ public IRubyObject initialize_copy(IRubyObject original) {
}
public boolean equals(Object other) {
+ if (this == other) return true;
if (!(other instanceof RubyMatchData)) return false;
RubyMatchData match = (RubyMatchData)other;
@@ -662,4 +665,12 @@ public boolean equals(Object other) {
public IRubyObject eql_p(IRubyObject obj) {
return getRuntime().newBoolean(equals(obj));
}
+
+ @JRubyMethod(name = "hash")
+ @Override
+ public RubyFixnum hash() {
+ check();
+ return getRuntime().newFixnum(regexp.hashCode() ^ str.hashCode());
+ }
+
}
View
7 src/org/jruby/RubyRegexp.java
@@ -1763,7 +1763,12 @@ public IRubyObject to_s() {
if (!newOptions.isExtended()) result.append((byte)'x');
}
result.append((byte)':');
- appendRegexpString(getRuntime(), result, bytes, p, len, getEncoding(runtime, str));
+ if (runtime.is1_9()) {
+ appendRegexpString19(runtime, result, bytes, p, len, getEncoding(runtime, str));
+ } else {
+ appendRegexpString(runtime, result, bytes, p, len, getEncoding(runtime, str));
+ }
+
result.append((byte)')');
return RubyString.newString(getRuntime(), result, getEncoding()).infectBy(this);
} while (true);

0 comments on commit 8d82e2e

Please sign in to comment.