Skip to content

Commit 924151c

Browse files
committed
MatchData#== should have the specs and #eql? be the alias
1 parent a70103f commit 924151c

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

core/matchdata/eql_spec.rb

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
require_relative '../../spec_helper'
22

33
describe "MatchData#eql?" do
4-
it "returns true if both operands have equal target strings, patterns, and match positions" do
5-
a = 'haystack'.match(/hay/)
6-
b = 'haystack'.match(/hay/)
7-
a.eql?(b).should == true
8-
end
9-
10-
it "returns false if the operands have different target strings" do
11-
a = 'hay'.match(/hay/)
12-
b = 'haystack'.match(/hay/)
13-
a.eql?(b).should == false
14-
end
15-
16-
it "returns false if the operands have different patterns" do
17-
a = 'haystack'.match(/h.y/)
18-
b = 'haystack'.match(/hay/)
19-
a.eql?(b).should == false
20-
end
21-
22-
it "returns false if the argument is not a MatchData object" do
23-
a = 'haystack'.match(/hay/)
24-
a.eql?(Object.new).should == false
4+
it "is an alias of MatchData#==" do
5+
MatchData.instance_method(:eql?).should == MatchData.instance_method(:==)
256
end
267
end

core/matchdata/equal_value_spec.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
require_relative '../../spec_helper'
22

33
describe "MatchData#==" do
4-
it "is an alias of MatchData#eql?" do
5-
MatchData.instance_method(:==).should == MatchData.instance_method(:eql?)
4+
it "returns true if both operands have equal target strings, patterns, and match positions" do
5+
a = 'haystack'.match(/hay/)
6+
b = 'haystack'.match(/hay/)
7+
a.==(b).should == true
68
end
7-
end
9+
10+
it "returns false if the operands have different target strings" do
11+
a = 'hay'.match(/hay/)
12+
b = 'haystack'.match(/hay/)
13+
a.==(b).should == false
14+
end
15+
16+
it "returns false if the operands have different patterns" do
17+
a = 'haystack'.match(/h.y/)
18+
b = 'haystack'.match(/hay/)
19+
a.==(b).should == false
20+
end
21+
22+
it "returns false if the argument is not a MatchData object" do
23+
a = 'haystack'.match(/hay/)
24+
a.==(Object.new).should == false
25+
end
26+
end

0 commit comments

Comments
 (0)