Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Regexp #== and #eql? is true if self does not specify /n option and other does and vise versa #694

Merged
merged 1 commit into from May 3, 2013
Jump to file or symbol
Failed to load files and symbols.
+13 −12
Split
@@ -1,2 +0,0 @@
-fails:Regexp#eql? is true if self does not specify /n option and other does
-fails:Regexp#eql? is true if self specifies /n option and other does not
@@ -1,2 +0,0 @@
-fails:Regexp#== is true if self does not specify /n option and other does
-fails:Regexp#== is true if self specifies /n option and other does not
@@ -253,14 +253,19 @@ public boolean equals(Object other) {
// sake of equality we ignore those two fields since those flags do
// not affect Ruby equality.
RegexpOptions o = (RegexpOptions)other;
- return o.encodingNone == encodingNone &&
- o.extended == extended &&
- o.fixed == fixed &&
- o.ignorecase == ignorecase &&
- o.java == java &&
- o.kcode == kcode &&
- o.kcodeDefault == kcodeDefault &&
- o.multiline == multiline;
+ boolean equality = o.extended == extended &&
+ o.fixed == fixed &&
+ o.ignorecase == ignorecase &&
+ o.java == java &&
+ o.multiline == multiline;
+ if(encodingNone || o.encodingNone) {
+ return equality && o.kcode == kcode;
+ } else {
+ return equality &&
+ o.encodingNone == encodingNone &&
+ o.kcode == kcode &&
+ o.kcodeDefault == kcodeDefault;
+ }
}
@Override