This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
covers 'facets/regexp/arity'
|
||||
|
||||
test_case Regexp do
|
||||
|
||||
method :arity do
|
||||
|
||||
test do
|
||||
r = /(1)(2)(3)/
|
||||
r.arity.assert == 3
|
||||
end
|
||||
|
||||
test do
|
||||
r = /(1)(2)(3)(4)/
|
||||
r.arity.assert == 4
|
||||
end
|
||||
|
||||
test do
|
||||
r = /(1)(2)((a)3)/
|
||||
r.arity.assert == 4
|
||||
end
|
||||
|
||||
test do
|
||||
r = /(?#nothing)(1)(2)(3)(?=3)/
|
||||
r.arity.assert == 3
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
covers 'facets/regexp/multiline'
|
||||
|
||||
test_case Regexp do
|
||||
|
||||
method :multiline? do
|
||||
|
||||
test do
|
||||
re = /x/m
|
||||
re.assert.multiline?
|
||||
end
|
||||
|
||||
test do
|
||||
re = /x/
|
||||
re.refute.multiline?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
covers 'facets/regexp/op_add'
|
||||
|
||||
test_case Regexp do
|
||||
|
||||
method :+ do
|
||||
|
||||
test do
|
||||
r = /a/ + /b/
|
||||
r.assert == /(?-mix:a)(?-mix:b)/
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
covers 'facets/regexp/op_or'
|
||||
|
||||
test_case Regexp do
|
||||
|
||||
method :| do
|
||||
|
||||
test do
|
||||
re = /a/ | /b/
|
||||
re.assert =~ "a"
|
||||
re.assert =~ "b"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
covers 'facets/regexp/to_re'
|
||||
|
||||
test_case Regexp do
|
||||
|
||||
method :to_re do
|
||||
|
||||
test do
|
||||
r = /0..10/
|
||||
r.to_re.assert == r.to_re
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
method :to_regexp do
|
||||
|
||||
test do
|
||||
r = /0..10/
|
||||
r.to_regexp.assert == r
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user