harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r979659 - in /harmony/enhanced/java/trunk/classlib/modules/regex/src: main/java/java/util/regex/Matcher.java test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
Date Tue, 27 Jul 2010 12:09:54 GMT
Author: tellison
Date: Tue Jul 27 12:09:54 2010
New Revision: 979659

URL: http://svn.apache.org/viewvc?rev=979659&view=rev
Log:
Apply patch for HARMONY-6600 ([classlib][regex]Matcher does not override the toString() mentioned
in spec on harmony 5)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/regex/src/main/java/java/util/regex/Matcher.java
    harmony/enhanced/java/trunk/classlib/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/regex/src/main/java/java/util/regex/Matcher.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/regex/src/main/java/java/util/regex/Matcher.java?rev=979659&r1=979658&r2=979659&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/regex/src/main/java/java/util/regex/Matcher.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/regex/src/main/java/java/util/regex/Matcher.java
Tue Jul 27 12:09:54 2010
@@ -687,4 +687,16 @@ public final class Matcher implements Ma
         matchResult = new MatchResultImpl(cs, leftBound, rightBound, pat
                 .groupCount(), pat.compCount(), pat.consCount());
     }
+
+    @Override
+    public String toString() {
+        String lastMatch = "";
+        try {
+            lastMatch = Integer.toString(start());
+        } catch (IllegalStateException e) {
+        }
+        return getClass().getCanonicalName() + "[pattern=" + pat + " region="
+                + matchResult.getLeftBound() + ","
+                + matchResult.getRightBound() + " lastmatch=" + lastMatch + "]";
+    }
 }

Modified: harmony/enhanced/java/trunk/classlib/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java?rev=979659&r1=979658&r2=979659&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
Tue Jul 27 12:09:54 2010
@@ -735,6 +735,16 @@ public class MatcherTest extends TestCas
                 "----1 fish 2 fish red fish 5----", false);
     }
 
+    /*
+     * Test if Matcher's toString conatain pattern information
+     */
+    public void testToString() {
+        String result = Pattern.compile("(\\d{1,3})").matcher(
+                "aaaa123456789045").toString();
+        assertTrue("The result doesn't contain pattern info", result
+                .contains("(\\d{1,3})"));
+    }
+
     private void hitEndTest(boolean callFind, String testNo, String regex,
             String input, boolean hit) {
         Pattern pattern = Pattern.compile(regex);



Mime
View raw message