Author: gert
Date: 2005-06-27 14:47:38 -0400 (Mon, 27 Jun 2005)
New Revision: 46587

Added:
   
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs
Modified:
   trunk/mcs/class/System/ChangeLog
   trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog
   trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
   trunk/mcs/class/System/System_test.dll.sources
   trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog
Log:
* CodeGeneratorFromExpressionTest.cs: Added tests for 
GenerateCodeFromExpression.
* System_test.dll.sources: Added CodeGeneratorFromExpressionTest.cs
from Microsoft.VisualBasic.
* VBCodeGenerator.cs: Added short type names for which support was
added in .NET 2.0. Added support for Date.


Modified: trunk/mcs/class/System/ChangeLog
===================================================================
--- trunk/mcs/class/System/ChangeLog    2005-06-27 18:42:32 UTC (rev 46586)
+++ trunk/mcs/class/System/ChangeLog    2005-06-27 18:47:38 UTC (rev 46587)
@@ -1,5 +1,10 @@
 2005-06-27 Gert Driesen <[EMAIL PROTECTED]>
 
+       * System_test.dll.sources: Added CodeGeneratorFromExpressionTest.cs
+       from Microsoft.VisualBasic.
+
+2005-06-27 Gert Driesen <[EMAIL PROTECTED]>
+
        * System_test.dll.sources: Added CodeMemberPropertyTest.cs from
        System.CodeDom.
 

Modified: trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog
===================================================================
--- trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog      2005-06-27 
18:42:32 UTC (rev 46586)
+++ trunk/mcs/class/System/Microsoft.VisualBasic/ChangeLog      2005-06-27 
18:47:38 UTC (rev 46587)
@@ -1,3 +1,8 @@
+2005-06-27  Gert Driesen <[EMAIL PROTECTED]>
+
+       * VBCodeGenerator.cs: Added short type names for which support was
+       added in .NET 2.0. Added support for Date. 
+
 2005-06-26  Gert Driesen <[EMAIL PROTECTED]>
 
        * VBCodeGenerator.cs: Minor fixes for compatibility with MS.NET 2.0.

Modified: trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs
===================================================================
--- trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs     
2005-06-27 18:42:32 UTC (rev 46586)
+++ trunk/mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs     
2005-06-27 18:47:38 UTC (rev 46587)
@@ -1245,6 +1245,9 @@
                                output = GetTypeOutput (arrayType);
                        else { 
                                switch (type.BaseType) {
+                               case "System.DateTime":
+                                       output = "Date";
+                                       break;
                                case "System.Decimal":
                                        output = "Decimal";
                                        break;
@@ -1278,6 +1281,20 @@
                                case "System.Object":
                                        output = "Object";
                                        break;
+#if NET_2_0
+                               case "System.SByte":
+                                       output = "SByte";
+                                       break;
+                               case "System.UInt16":
+                                       output = "UShort";
+                                       break;
+                               case "System.UInt32":
+                                       output = "UInteger";
+                                       break;
+                               case "System.UInt64":
+                                       output = "ULong";
+                                       break;
+#endif
                                default:
                                        output = type.BaseType;
                                        break;

Modified: trunk/mcs/class/System/System_test.dll.sources
===================================================================
--- trunk/mcs/class/System/System_test.dll.sources      2005-06-27 18:42:32 UTC 
(rev 46586)
+++ trunk/mcs/class/System/System_test.dll.sources      2005-06-27 18:47:38 UTC 
(rev 46587)
@@ -9,6 +9,7 @@
 Microsoft.VisualBasic/CodeGeneratorTestBase.cs
 Microsoft.VisualBasic/VBCodeProviderTest.cs
 Microsoft.VisualBasic/CodeGeneratorFromCompileUnitTest.cs
+Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs
 Microsoft.VisualBasic/CodeGeneratorFromTypeTest.cs
 System/UriBuilderTest.cs
 System/UriTest.cs

Modified: trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog 2005-06-27 
18:42:32 UTC (rev 46586)
+++ trunk/mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog 2005-06-27 
18:47:38 UTC (rev 46587)
@@ -1,3 +1,8 @@
+2005-06-27  Gert Driesen <[EMAIL PROTECTED]>
+
+       * CodeGeneratorFromExpressionTest.cs: Added tests for 
+       GenerateCodeFromExpression.
+
 2005-06-26  Gert Driesen <[EMAIL PROTECTED]>
 
        * CodeGeneratorFromTypeTest.cs: Make tests pass on MS.NET 1.x and 2.0,

Added: 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs
===================================================================
--- 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs
        2005-06-27 18:42:32 UTC (rev 46586)
+++ 
trunk/mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs
        2005-06-27 18:47:38 UTC (rev 46587)
@@ -0,0 +1,111 @@
+//
+// Microsoft.VisualBasic.* Test Cases
+//
+// Authors:
+//     Gert Driesen ([EMAIL PROTECTED])
+//
+// (c) 2005 Novell
+//
+using System;
+using System.IO;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using Microsoft.VisualBasic;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.VisualBasic
+{
+       [TestFixture]
+       public class CodeGeneratorFromExpressionTest
+       {
+               VBCodeProvider provider;
+               ICodeGenerator generator;
+               CodeGeneratorOptions options;
+
+               [SetUp]
+               public void SetUp ()
+               {
+                       provider = new VBCodeProvider ();
+                       generator = provider.CreateGenerator ();
+                       options = new CodeGeneratorOptions ();
+               }
+               
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void DefaultExpressionTest ()
+               {
+                       using (StringWriter sw = new StringWriter ()) {
+                               Generate(new CodeExpression (), sw);
+                               sw.Close ();
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void NullExpressionTest ()
+               {
+                       using (StringWriter sw = new StringWriter ()) {
+                               Generate (null, sw);
+                       }
+               }
+
+               [Test]
+               public void TypeReferenceExpressionTest ()
+               {
+                       StringBuilder sb = new StringBuilder();
+
+                       using (StringWriter sw = new StringWriter (sb)) {
+                               Assert.AreEqual ("Boolean", Generate (new 
CodeTypeReferenceExpression (typeof (bool)), sw), "#1");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Byte", Generate (new 
CodeTypeReferenceExpression (typeof (byte)), sw), "#2");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Char", Generate (new 
CodeTypeReferenceExpression (typeof (char)), sw), "#3");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Date", Generate (new 
CodeTypeReferenceExpression (typeof (DateTime)), sw), "#4");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Decimal", Generate (new 
CodeTypeReferenceExpression (typeof (decimal)), sw), "#5");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Double", Generate (new 
CodeTypeReferenceExpression (typeof (double)), sw), "#6");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Short", Generate (new 
CodeTypeReferenceExpression (typeof (short)), sw), "#7");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Integer", Generate (new 
CodeTypeReferenceExpression (typeof (int)), sw), "#8");
+                               sb.Length = 0;
+                               Assert.AreEqual ("Long", Generate (new 
CodeTypeReferenceExpression (typeof (long)), sw), "#9");
+                               sb.Length = 0;
+#if NET_2_0
+                               Assert.AreEqual ("SByte", Generate (new 
CodeTypeReferenceExpression (typeof (sbyte)), sw), "#10");
+                               sb.Length = 0;
+                               Assert.AreEqual ("UShort", Generate (new 
CodeTypeReferenceExpression (typeof (ushort)), sw), "#11");
+                               sb.Length = 0;
+                               Assert.AreEqual ("UInteger", Generate (new 
CodeTypeReferenceExpression (typeof (uint)), sw), "#12");
+                               sb.Length = 0;
+                               Assert.AreEqual ("ULong", Generate (new 
CodeTypeReferenceExpression (typeof (ulong)), sw), "#13");
+                               sb.Length = 0;
+#else
+                               Assert.AreEqual (typeof (sbyte).FullName, 
Generate (new CodeTypeReferenceExpression (typeof (sbyte)), sw), "#14");
+                               sb.Length = 0;
+                               Assert.AreEqual (typeof(ushort).FullName, 
Generate (new CodeTypeReferenceExpression (typeof (ushort)), sw), "#15");
+                               sb.Length = 0;
+                               Assert.AreEqual (typeof(uint).FullName, 
Generate (new CodeTypeReferenceExpression (typeof (uint)), sw), "#16");
+                               sb.Length = 0;
+                               Assert.AreEqual (typeof(ulong).FullName, 
Generate (new CodeTypeReferenceExpression (typeof (ulong)), sw), "#17");
+                               sb.Length = 0;
+#endif
+                               Assert.AreEqual ("Single", Generate (new 
CodeTypeReferenceExpression (typeof (float)), sw), "#18");
+                               sb.Length = 0;
+                               Assert.AreEqual (typeof(void).FullName, 
Generate (new CodeTypeReferenceExpression (typeof (void)), sw), "#19");
+                               sw.Close ();
+                       }
+               }
+
+               private string Generate (CodeExpression expression, 
StringWriter sw)
+               {
+                       generator.GenerateCodeFromExpression (expression, sw, 
options);
+                       return sw.ToString ();
+               }
+       }
+}

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

Reply via email to