Author: gert
Date: 2007-11-01 16:17:50 -0500 (Thu, 01 Nov 2007)
New Revision: 88685

Modified:
   trunk/mcs/class/System/System.Text.RegularExpressions/ChangeLog
   trunk/mcs/class/System/System.Text.RegularExpressions/Match.cs
   trunk/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog
   trunk/mcs/class/System/Test/System.Text.RegularExpressions/GroupTest.cs
   trunk/mcs/class/System/Test/System.Text.RegularExpressions/MatchTest.cs
   trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexMatchTests.cs
   
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexResultTests.cs
   trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs
Log:
* GroupTest.cs: Improved test for null argument check.
* MatchTest.cs: Improved tests for null argument checks. Added and
fixed replacement tests.
* RegexMatchTest.cs: Marked tests that do not pass on MS as NotDotNet.
Fixed expected result for trial 5.
* RegexResultTests.cs: Fixed Assert.
* Match.cs: Do not throw NotSupportedException on zero-length 
replacement argument.


Modified: trunk/mcs/class/System/System.Text.RegularExpressions/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Text.RegularExpressions/ChangeLog     
2007-11-01 21:13:48 UTC (rev 88684)
+++ trunk/mcs/class/System/System.Text.RegularExpressions/ChangeLog     
2007-11-01 21:17:50 UTC (rev 88685)
@@ -1,3 +1,8 @@
+2007-11-01  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * Match.cs: Do not throw NotSupportedException on zero-length
+       replacement argument.
+
 2007-10-29 Arina Itkes <[EMAIL PROTECTED]>
 
        * Regex.cs: Moving creation of Regex machine to ctor.

Modified: trunk/mcs/class/System/System.Text.RegularExpressions/Match.cs
===================================================================
--- trunk/mcs/class/System/System.Text.RegularExpressions/Match.cs      
2007-11-01 21:13:48 UTC (rev 88684)
+++ trunk/mcs/class/System/System.Text.RegularExpressions/Match.cs      
2007-11-01 21:17:50 UTC (rev 88685)
@@ -66,8 +66,6 @@
                {
                        if (replacement == null)
                                throw new ArgumentNullException ("replacement");
-                       if (replacement.Length == 0)
-                               throw new NotSupportedException ();
                        if (machine == null)
                                throw new NotSupportedException ("Result cannot 
be called on failed Match.");
 

Modified: trunk/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog        
2007-11-01 21:13:48 UTC (rev 88684)
+++ trunk/mcs/class/System/Test/System.Text.RegularExpressions/ChangeLog        
2007-11-01 21:17:50 UTC (rev 88685)
@@ -1,3 +1,12 @@
+2007-11-01  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * GroupTest.cs: Improved test for null argument check.
+       * MatchTest.cs: Improved tests for null argument checks. Added and
+       fixed replacement tests.
+       * RegexMatchTest.cs: Marked tests that do not pass on MS as NotDotNet.
+       Fixed expected result for trial 5.
+       * RegexResultTests.cs: Fixed Assert.
+
 2007-10-29 Arina Itkes <[EMAIL PROTECTED]>
 
        * RegexReplace.cs RegxMatchTests.cs RegexResultTests.cs

Modified: 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/GroupTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Text.RegularExpressions/GroupTest.cs     
2007-11-01 21:13:48 UTC (rev 88684)
+++ trunk/mcs/class/System/Test/System.Text.RegularExpressions/GroupTest.cs     
2007-11-01 21:17:50 UTC (rev 88685)
@@ -31,16 +31,24 @@
 using System;
 using System.Text.RegularExpressions;
 
-namespace MonoTests.System.Text.RegularExpressions {
-
+namespace MonoTests.System.Text.RegularExpressions
+{
        [TestFixture]
-       public class GroupTest {
-
+       public class GroupTest
+       {
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void Synchronized_Null ()
+               public void Synchronized_Inner_Null ()
                {
-                       Group.Synchronized (null);
+                       try {
+                               Group.Synchronized (null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof 
(ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("inner", ex.ParamName, "#6");
+                       }
                }
 
                [Test]
@@ -48,7 +56,7 @@
                {
                        Group eg = Match.Empty.Groups[0];
                        Group sg = Match.Synchronized (eg);
-                       Assert.IsTrue (Object.ReferenceEquals (eg, sg), 
"Synchronized");
+                       Assert.AreSame (eg, sg, "Synchronized");
                }
        }
 }

Modified: 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/MatchTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Text.RegularExpressions/MatchTest.cs     
2007-11-01 21:13:48 UTC (rev 88684)
+++ trunk/mcs/class/System/Test/System.Text.RegularExpressions/MatchTest.cs     
2007-11-01 21:17:50 UTC (rev 88685)
@@ -37,10 +37,18 @@
        public class MatchTest
        {
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void Synchronized_Null ()
+               public void Synchronized_Inner_Null ()
                {
-                       Match.Synchronized (null);
+                       try {
+                               Match.Synchronized (null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof 
(ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("inner", ex.ParamName, "#6");
+                       }
                }
 
                [Test]
@@ -48,21 +56,45 @@
                {
                        Match em = Match.Empty;
                        Match sm = Match.Synchronized (em);
-                       Assert.IsTrue (Object.ReferenceEquals (em, sm), 
"Synchronized");
+                       Assert.AreSame (em, sm, "Synchronized");
                }
 
                [Test]
-               [ExpectedException (typeof (ArgumentNullException))]
-               public void Result_Null ()
+               public void Result_Replacement_Null ()
                {
-                       Match.Empty.Result (null);
+                       try {
+                               Match.Empty.Result (null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof 
(ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("replacement", ex.ParamName, 
"#6");
+                       }
                }
 
                [Test]
-               [ExpectedException (typeof (NotSupportedException))]
-               public void Result_Empty ()
+               public void Result_Replacement_Empty ()
                {
-                       Match.Empty.Result (String.Empty);
+                       Regex email = new Regex ("(?<user>[EMAIL 
PROTECTED])@(?<domain>.+)");
+                       Match m = email.Match ("[EMAIL PROTECTED]");
+                       string exp = m.Result (string.Empty);
+                       Assert.AreEqual (string.Empty, exp);
                }
+
+               [Test]
+               public void Result_Match_Empty ()
+               {
+                       try {
+                               Match.Empty.Result ("whatever");
+                               Assert.Fail ("#1");
+                       } catch (NotSupportedException ex) {
+                               // Result cannot be called on failed Match
+                               Assert.AreEqual (typeof 
(NotSupportedException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                       }
+               }
        }
 }

Modified: 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexMatchTests.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexMatchTests.cs   
    2007-11-01 21:13:48 UTC (rev 88684)
+++ 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexMatchTests.cs   
    2007-11-01 21:17:50 UTC (rev 88685)
@@ -27,7 +27,7 @@
                        + " Group[10]=(9,2)"
                        + " Group[11]=(11,1)"
                        ),
-                       new RegexTrial 
(@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.ExplicitCapture, 
"F2345678910LL", "Fail"),//5
+                       new RegexTrial 
(@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.ExplicitCapture, 
"F2345678910LL", "Fail."),//5
                        new RegexTrial 
(@"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\1", RegexOptions.None, 
"F2345678910L71", "Fail."),//6
                        new RegexTrial 
(@"(F)(2)(3)(4)(5)(6)(7)(8)(9)(10)(L)\11", RegexOptions.None, "F2345678910LF1", 
"Fail."),//7
                        new RegexTrial 
(@"(F)(2)(3)(4)(5)(6)(?<S>7)(8)(9)(10)(L)\11", RegexOptions.None, 
"F2345678910L71", "Pass."//8
@@ -150,64 +150,139 @@
                        new RegexTrial (@"(?>a*).", 
RegexOptions.ExplicitCapture, "aaaa", "Fail."),//52
                };
 
-               [Test]  public void RegexJvmTrial0000 () { trials [0].Execute 
(); }
-               [Test]  public void RegexJvmTrial0001 () { trials [1].Execute 
(); }
+               [Test]
+               public void RegexJvmTrial0000 ()
+               {
+                       trials [0].Execute ();
+               }
 
                [Test]
+               public void RegexJvmTrial0001 ()
+               {
+                       trials [1].Execute ();
+               }
+
+               [Test]
+               [Category ("NotDotNet")]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0002 () { trials [2].Execute (); }
+               public void RegexJvmTrial0002 ()
+               {
+                       trials [2].Execute ();
+               }
 
-               [Test]  public void RegexJvmTrial0003 () { trials [3].Execute 
(); }
-               [Test]  public void RegexJvmTrial0004 () { trials [4].Execute 
(); }
+               [Test]
+               public void RegexJvmTrial0003 ()
+               {
+                       trials [3].Execute ();
+               }
 
                [Test]
+               public void RegexJvmTrial0004 ()
+               {
+                       trials [4].Execute ();
+               }
+
+               [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0005 () { trials [5].Execute (); }
+               public void RegexJvmTrial0005 ()
+               {
+                       trials [5].Execute ();
+               }
 
-               [Test]  public void RegexJvmTrial0006 () { trials [6].Execute 
(); }
-               [Test]  public void RegexJvmTrial0007 () { trials [7].Execute 
(); }
+               [Test]
+               public void RegexJvmTrial0006 ()
+               {
+                       trials [6].Execute ();
+               }
 
                [Test]
+               public void RegexJvmTrial0007 ()
+               {
+                       trials [7].Execute ();
+               }
+
+               [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0008 () { trials [8].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0008 ()
+               {
+                       trials [8].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0009 () { trials [9].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0009 ()
+               {
+                       trials [9].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0010 () { trials [10].Execute (); }
+               public void RegexJvmTrial0010 ()
+               {
+                       trials [10].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0011 () { trials [11].Execute (); }
+               public void RegexJvmTrial0011 ()
+               {
+                       trials [11].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0012 () { trials [12].Execute (); }
+               public void RegexJvmTrial0012 ()
+               {
+                       trials [12].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0013 () { trials [13].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0013 ()
+               {
+                       trials [13].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0014 () { trials [14].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0014 ()
+               {
+                       trials [14].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0015 () { trials [15].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0015 ()
+               {
+                       trials [15].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0016 () { trials [16].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0016 ()
+               {
+                       trials [16].Execute ();
+               }
 
-               [Test]  public void RegexJvmTrial0017 () { trials [17].Execute 
(); }
+               [Test]
+               public void RegexJvmTrial0017 ()
+               {
+                       trials [17].Execute ();
+               }
 
                [Test]
                [Category ("NotWorking")]
-               public void RegexJvmTrial0018 () { trials [18].Execute (); }
+               [Category ("NotDotNet")]
+               public void RegexJvmTrial0018 ()
+               {
+                       trials [18].Execute ();
+               }
                
                [Test]  public void RegexJvmTrial0019 () { trials [19].Execute 
(); }
                [Test]  public void RegexJvmTrial0020 () { trials [20].Execute 
(); }

Modified: 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexResultTests.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexResultTests.cs  
    2007-11-01 21:13:48 UTC (rev 88684)
+++ 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexResultTests.cs  
    2007-11-01 21:17:50 UTC (rev 88685)
@@ -27,8 +27,8 @@
                                catch (Exception e) {
                                        result = "Error.";
                                }
-                               Assert.AreEqual (result, expected, "rr#: {1} ~ 
s,{2},{3},",
-                               original, pattern, replacement);
+                               Assert.AreEqual (expected, result, "rr#: {0} ~ 
s,{1},{2},",
+                                       original, pattern, replacement);
 
                        }
                }


Property changes on: 
trunk/mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to