modalsupport 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/modalsupport/regexp.rb +1 -1
- data/lib/modalsupport/string.rb +1 -1
- data/modalsupport.gemspec +1 -1
- data/test/test_match.rb +8 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/modalsupport/regexp.rb
CHANGED
data/lib/modalsupport/string.rb
CHANGED
data/modalsupport.gemspec
CHANGED
data/test/test_match.rb
CHANGED
@@ -2,11 +2,18 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestGsub < Test::Unit::TestCase
|
4
4
|
|
5
|
-
should "pass match info to a block" do
|
5
|
+
should "pass match info to a block and return the block result" do
|
6
6
|
assert_equal "axa", "xxx axa yue asx aya aza".match_one(/a.a/){|match| match.to_s}
|
7
7
|
assert_equal "axa", /a.a/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
|
8
8
|
end
|
9
9
|
|
10
|
+
should "return nil if no match" do
|
11
|
+
assert_equal "axa", "xxx axa yue asx aya aza".match_one(/a.a/){|match| match.to_s}
|
12
|
+
assert_equal "axa", /a.a/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
|
13
|
+
assert_nil "xxx axa yue asx aya aza".match_one(/b.b/){|match| match.to_s}
|
14
|
+
assert_nil /b.b/.match_one("xxx axa yue asx aya aza"){|match| match.to_s}
|
15
|
+
end
|
16
|
+
|
10
17
|
should "map all matches to an array" do
|
11
18
|
assert_equal ["axa", "aya", "aza"], "xxx axa yue asx aya aza".match_all(/a.a/){|match| match.to_s}
|
12
19
|
assert_equal ["axa", "aya", "aza"], /a.a/.match_all("xxx axa yue asx aya aza"){|match| match.to_s}
|