-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment
%: uname -a
Linux centos7andy.jhallpr.com 3.10.0-327.18.2.el7.x86_64 #1 SMP Thu May 12 11:03:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
%: jruby -v
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 OpenJDK 64-Bit Server VM 25.91-b14 on 1.8.0_91-b14 [linux-x86_64]
Expected Behavior
"Things equal to the same thing are equal to each other" -- Euclid
Regardless of how a Regexp is created or what it contains, identical Regexp should always be equal to each other.
The behaviour below turns up in MRI 1.9.3, too, but appears to be gone by 2.0.0:
%: rvm use ruby-2.0.0
Using /home/jonea/.rvm/gems/ruby-2.0.0-p648
%: irb
2.0.0-p648 :001 > %r|foo/bar| == /foo\/bar/
=> true
%: rvm use ruby-1.9.3
Using /home/jonea/.rvm/gems/ruby-1.9.3-p551
%: irb
1.9.3-p551 :001 > %r|foo/bar| == /foo\/bar/
=> false
Actual Behavior
%: jirb
:001 > /foo\/bar/ == Regexp.new("foo/bar")
=> false
:002 > /foo\/bar/ == Regexp.new("foo\/bar")
=> false
:003 > /foo\/bar/ == %r|foo/bar|
=> false
:004 > %r|foo/bar| == Regexp.new("foo\/bar")
=> true
:005 > /foobar/ == %r|foobar|
=> true
As you can see, the problem seems to be with Regexp created using the basic slash syntax when the regexp itself also contains a slash.
Reactions are currently unavailable