Author: martin
Date: 2008-01-23 04:32:37 -0500 (Wed, 23 Jan 2008)
New Revision: 93631

Added:
   branches/martin/debugger-terrania/debugger/test/src/TestSimpleGenerics.cs
   
branches/martin/debugger-terrania/debugger/test/testsuite/TestSimpleGenerics.cs
Modified:
   branches/martin/debugger-terrania/debugger/ChangeLog
   branches/martin/debugger-terrania/debugger/test/src/Makefile.am
   branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
Log:
2008-01-23  Martin Baulig  <[EMAIL PROTECTED]>

        * test/{testsuite|src}/TestSimpleGenerics.cs: New test.



Modified: branches/martin/debugger-terrania/debugger/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/debugger/ChangeLog        2008-01-23 
08:43:17 UTC (rev 93630)
+++ branches/martin/debugger-terrania/debugger/ChangeLog        2008-01-23 
09:32:37 UTC (rev 93631)
@@ -1,3 +1,7 @@
+2008-01-23  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * test/{testsuite|src}/TestSimpleGenerics.cs: New test.
+
 2008-01-19  Martin Baulig  <[EMAIL PROTECTED]>
 
        * configure.in: Use gmcs, not mcs.

Modified: branches/martin/debugger-terrania/debugger/test/src/Makefile.am
===================================================================
--- branches/martin/debugger-terrania/debugger/test/src/Makefile.am     
2008-01-23 08:43:17 UTC (rev 93630)
+++ branches/martin/debugger-terrania/debugger/test/src/Makefile.am     
2008-01-23 09:32:37 UTC (rev 93631)
@@ -12,7 +12,7 @@
        TestBreakpoint.cs TestNamespace.cs TestException.cs \
        TestRestart.cs TestExec.cs TestChild.cs TestAttach.cs \
        TestMethodLookup.cs TestMultiThread.cs TestSession.cs \
-       TestCCtor.cs
+       TestCCtor.cs TestSimpleGenerics.cs
 
 EXTRA_TEST_SRC = \
        TestAppDomain.cs TestAppDomain-Module.cs TestAppDomain-Hello.cs \

Added: branches/martin/debugger-terrania/debugger/test/src/TestSimpleGenerics.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/test/src/TestSimpleGenerics.cs   
2008-01-23 08:43:17 UTC (rev 93630)
+++ branches/martin/debugger-terrania/debugger/test/src/TestSimpleGenerics.cs   
2008-01-23 09:32:37 UTC (rev 93631)
@@ -0,0 +1,71 @@
+using System;
+
+public class Hello<S>
+{
+       public void World (S s)
+       {
+               Console.WriteLine (s);
+       }
+}
+
+public class Foo<T>
+{
+       public readonly T Data;
+
+       public Foo (T t)
+       {
+               this.Data = t;
+       }
+
+       public void Hello ()
+       {
+               Console.WriteLine (Data);
+       }
+}
+
+public class Bar<U> : Foo<U>
+{
+       public Bar (U u)
+               : base (u)
+       { }
+}
+
+public class Baz<U> : Foo<Hello<U>>
+{
+       public Baz (U u)
+               : base (new Hello<U> ())
+       { }
+}
+
+public class Test : Foo<int>
+{
+       public Test ()
+               : base (9)
+       { }
+
+       public static void Hello<T> (T t)
+       {
+               Console.WriteLine (t);
+       }
+}
+
+class X
+{
+       static void Main ()
+       {
+               Foo<int> foo = new Foo<int> (5);
+               foo.Hello ();
+
+               Bar<int> bar = new Bar<int> (5);
+               bar.Hello ();
+
+               Baz<int> baz = new Baz<int> (5);
+               baz.Data.World (8);
+               baz.Hello ();
+
+               Test test = new Test ();
+               test.Hello ();
+               Test.Hello (8);
+               Test.Hello ("World");
+       }
+}

Modified: branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs
===================================================================
--- branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs  
2008-01-23 08:43:17 UTC (rev 93630)
+++ branches/martin/debugger-terrania/debugger/test/testsuite/NUnit.cs  
2008-01-23 09:32:37 UTC (rev 93631)
@@ -5,6 +5,7 @@
 using SD = System.Diagnostics;
 using ST = System.Threading;
 using System.Text;
+using System.Text.RegularExpressions;
 using NUnit.Framework;
 
 using Mono.Debugger;
@@ -623,6 +624,28 @@
                                             expression, text, exp_result);
                }
 
+               public void AssertPrintRegex (Thread thread, DisplayFormat 
format,
+                                             string expression, string exp_re)
+               {
+                       string text = null;
+                       try {
+                               ScriptingContext context = GetContext (thread);
+
+                               object obj = EvaluateExpression (context, 
expression);
+                               text = context.FormatObject (obj, format);
+                       } catch (AssertionException) {
+                               throw;
+                       } catch (Exception ex) {
+                               Assert.Fail ("Failed to print expression `{0}': 
{1}",
+                                            expression, ex);
+                       }
+
+                       Match match = Regex.Match (text, exp_re);
+                       if (!match.Success)
+                               Assert.Fail ("Expression `{0}' evaluated to 
`{1}', but expected `{2}'.",
+                                            expression, text, exp_re);
+               }
+
                public void AssertPrintException (Thread thread, string 
expression, string exp_result)
                {
                        string text = null;

Added: 
branches/martin/debugger-terrania/debugger/test/testsuite/TestSimpleGenerics.cs
===================================================================
--- 
branches/martin/debugger-terrania/debugger/test/testsuite/TestSimpleGenerics.cs 
    2008-01-23 08:43:17 UTC (rev 93630)
+++ 
branches/martin/debugger-terrania/debugger/test/testsuite/TestSimpleGenerics.cs 
    2008-01-23 09:32:37 UTC (rev 93631)
@@ -0,0 +1,93 @@
+using System;
+using NUnit.Framework;
+
+using Mono.Debugger;
+using Mono.Debugger.Languages;
+using Mono.Debugger.Frontend;
+
+namespace Mono.Debugger.Tests
+{
+       [TestFixture]
+       public class TestSimpleGenerics : TestSuite
+       {
+               public TestSimpleGenerics ()
+                       : base ("TestSimpleGenerics")
+               { }
+
+               const int LineFooHello = 22;
+
+               const int LineMain = 56;
+               const int LineMain2 = 60;
+               const int LineMain3 = 63;
+               const int LineMain4 = 67;
+
+               int bpt_main_2;
+               int bpt_main_3;
+               int bpt_main_4;
+
+               [Test]
+               [Category("Generics")]
+               public void Main ()
+               {
+                       Process process = Start ();
+                       Assert.IsTrue (process.IsManaged);
+                       Assert.IsTrue (process.MainThread.IsStopped);
+
+                       Thread thread = process.MainThread;
+
+                       AssertStopped (thread, "X.Main()", LineMain);
+                       bpt_main_2 = AssertBreakpoint (LineMain2);
+                       bpt_main_3 = AssertBreakpoint (LineMain3);
+                       bpt_main_4 = AssertBreakpoint (LineMain4);
+
+                       AssertExecute ("next");
+                       AssertStopped (thread, "X.Main()", LineMain + 1);
+
+                       AssertPrint (thread, "foo", "(Foo`1<int>) { Data = 5 
}");
+                       AssertType (thread, "foo",
+                                   "class Foo`1<int> = Foo`1<T> : 
System.Object\n" +
+                                   "{\n   T Data;\n   void Hello ();\n   .ctor 
(T);\n}");
+
+                       AssertExecute ("step");
+                       // FIXME: Use correct method name
+                       AssertStopped (thread, "Foo`1.Hello()", LineFooHello);
+
+                       AssertExecute ("continue");
+                       AssertTargetOutput ("5");
+                       AssertHitBreakpoint (thread, bpt_main_2, "X.Main()", 
LineMain2);
+
+                       AssertPrint (thread, "bar", "(Bar`1<int>) { 
<Foo`1<int>> = { Data = 5 } }");
+                       AssertType (thread, "bar",
+                                   "class Bar`1<int> = Bar`1<U> : 
Foo`1<U>\n{\n   .ctor (U);\n}");
+
+                       AssertExecute ("step");
+
+                       AssertStopped (thread, "Foo`1.Hello()", LineFooHello);
+
+                       AssertExecute ("continue");
+                       AssertTargetOutput ("5");
+                       AssertHitBreakpoint (thread, bpt_main_3, "X.Main()", 
LineMain3);
+
+                       AssertPrintRegex (thread, DisplayFormat.Object, "baz",
+                                         @"\(Baz`1<int>\) { 
<Foo`1<Hello`1<int>>> = { Data = \(Hello`1<int>\) 0x[0-9a-f]+ } }");
+                       AssertType (thread, "baz",
+                                   "class Baz`1<int> = Baz`1<U> : 
Foo`1<Hello`1<U>>\n{\n   .ctor (U);\n}");
+
+                       AssertExecute ("continue");
+                       AssertTargetOutput ("8");
+                       AssertTargetOutput ("Hello`1[System.Int32]");
+                       AssertHitBreakpoint (thread, bpt_main_4, "X.Main()", 
LineMain4);
+
+                       AssertPrint (thread, "test", "(Test) { <Foo`1<int>> = { 
Data = 9 } }");
+                       AssertType (thread, "test",
+                                   "class Test : Foo`1<int>\n{\n   static void 
Hello`1 (T);\n" +
+                                   "   .ctor ();\n}");
+
+                       AssertExecute ("continue");
+                       AssertTargetOutput ("9");
+                       AssertTargetOutput ("8");
+                       AssertTargetOutput ("World");
+                       AssertTargetExited (thread.Process);
+               }
+       }
+}

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

Reply via email to