summaryrefslogtreecommitdiff
path: root/spec/ruby/core/matchdata/shared/eql.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/matchdata/shared/eql.rb')
-rw-r--r--spec/ruby/core/matchdata/shared/eql.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/core/matchdata/shared/eql.rb b/spec/ruby/core/matchdata/shared/eql.rb
new file mode 100644
index 0000000000..098d82db5b
--- /dev/null
+++ b/spec/ruby/core/matchdata/shared/eql.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+
+describe :matchdata_eql, shared: true do
+ it "returns true if both operands have equal target strings, patterns, and match positions" do
+ a = 'haystack'.match(/hay/)
+ b = 'haystack'.match(/hay/)
+ a.send(@method, b).should be_true
+ end
+
+ it "returns false if the operands have different target strings" do
+ a = 'hay'.match(/hay/)
+ b = 'haystack'.match(/hay/)
+ a.send(@method, b).should be_false
+ end
+
+ it "returns false if the operands have different patterns" do
+ a = 'haystack'.match(/h.y/)
+ b = 'haystack'.match(/hay/)
+ a.send(@method, b).should be_false
+ end
+
+ it "returns false if the argument is not a MatchData object" do
+ a = 'haystack'.match(/hay/)
+ a.send(@method, Object.new).should be_false
+ end
+end