* system_linux_test.args: added new tests in Microsoft.CSharp.
* Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs:
* Microsoft.CSharp/CodeGeneratorFromExpressionTest.cs:
* Microsoft.CSharp/CodeGeneratorFromNamespaceTest.cs:
* Microsoft.CSharp/CodeGeneratorFromStatementTest.cs:
* Microsoft.CSharp/CodeGeneratorFromTypeTest.cs:
* Microsoft.CSharp/CodeGeneratorTestBase.cs: new tests from Erik LeBel
<eriklebel@yahoo.ca>.
svn path=/trunk/mcs/; revision=16054
+2003-07-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * system_linux_test.args: added new tests in Microsoft.CSharp.
+
+ * Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs:
+ * Microsoft.CSharp/CodeGeneratorFromExpressionTest.cs:
+ * Microsoft.CSharp/CodeGeneratorFromNamespaceTest.cs:
+ * Microsoft.CSharp/CodeGeneratorFromStatementTest.cs:
+ * Microsoft.CSharp/CodeGeneratorFromTypeTest.cs:
+ * Microsoft.CSharp/CodeGeneratorTestBase.cs: new tests from Erik LeBel
+ <eriklebel@yahoo.ca>.
+
2002-12-08 Jackson Harper <jackson@latitudegeo.com>
* CompilerTest.cs CompilerErrorTest.cs: Removed files
2002-11-06 Jackson Harper <jackson@latitudegeo.com>
- * AllTests.cs CompilerTest.cs: Added files
\ No newline at end of file
+ * AllTests.cs CompilerTest.cs: Added files
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+ ///
+ /// <summary>
+ /// Test ICodeGenerator's GenerateCodeFromCompileUnit, along with a
+ /// minimal set CodeDom components.
+ /// </summary>
+ ///
+ [TestFixture]
+ public class CodeGeneratorFromCompileUnitTest : CodeGeneratorTestBase
+ {
+ string codeUnitHeader = "";
+ CodeCompileUnit codeUnit = null;
+
+ public CodeGeneratorFromCompileUnitTest ()
+ {
+ Init();
+ Generate();
+ codeUnitHeader = Code;
+ }
+
+ [SetUp]
+ public void Init ()
+ {
+ InitBase ();
+ codeUnit = new CodeCompileUnit ();
+ }
+
+ protected override string Code {
+ get { return base.Code.Substring (codeUnitHeader.Length); }
+ }
+
+ protected override void Generate ()
+ {
+ generator.GenerateCodeFromCompileUnit (codeUnit, writer, options);
+ writer.Close ();
+ }
+
+ [Test]
+ public void DefaultCodeUnitTest ()
+ {
+ Generate ();
+ Assertion.AssertEquals ("", Code);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void NullCodeUnitTest ()
+ {
+ codeUnit = null;
+ Generate();
+ }
+
+ [Test]
+ public void ReferencedTest ()
+ {
+ codeUnit.ReferencedAssemblies.Add ("System.dll");
+ Generate();
+ Assertion.AssertEquals ("", Code);
+ }
+
+ [Test]
+ [Ignore ("This only differs in 4 spaces")]
+ public void SimpleNamespaceTest ()
+ {
+ CodeNamespace ns = new CodeNamespace ("A");
+ codeUnit.Namespaces.Add (ns);
+ Generate ();
+ Assertion.AssertEquals ("namespace A {\n \n}\n", Code);
+ }
+
+ [Test]
+ [Ignore ("This only differs in 4 spaces")]
+ public void ReferenceAndSimpleNamespaceTest()
+ {
+ CodeNamespace ns = new CodeNamespace ("A");
+ codeUnit.Namespaces.Add (ns);
+ codeUnit.ReferencedAssemblies.Add ("using System;");
+ Generate ();
+ Assertion.AssertEquals ("namespace A {\n \n}\n", Code);
+ }
+
+ [Test]
+ public void SimpleAttributeTest ()
+ {
+ CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
+ attrDec.Name = "A";
+
+ codeUnit.AssemblyCustomAttributes.Add (attrDec);
+ Generate ();
+ Assertion.AssertEquals ("[assembly: A()]\n\n", Code);
+ }
+
+ /* FIXME
+ [Test]
+ public void AttributeWithValueTest ()
+ {
+ CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
+ attrDec.Name = "A";
+
+
+ codeUnit.AssemblyCustomAttributes.Add (attrDec);
+ Generate ();
+ Assertion.AssertEquals ("[assembly: A()]\n\n", Code);
+ }*/
+
+ }
+}
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+ ///
+ /// <summary>
+ /// Test ICodeGenerator's GenerateCodeFromExpression, along with a
+ /// minimal set CodeDom components.
+ /// </summary>
+ ///
+ [TestFixture]
+ public class CodeGeneratorFromExpressionTest: CodeGeneratorTestBase
+ {
+ CodeExpression expression = null;
+
+ [SetUp]
+ public void Init ()
+ {
+ InitBase ();
+ expression = new CodeExpression ();
+ }
+
+ protected override void Generate ()
+ {
+ generator.GenerateCodeFromExpression (expression, writer, options);
+ writer.Close ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DefaultExpressionTest ()
+ {
+ Generate ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void NullExpressionTest ()
+ {
+ expression = null;
+ Generate ();
+ }
+
+ /*
+ [Test]
+ public void ReferencedTest ()
+ {
+ codeUnit.ReferencedAssemblies.Add ("System.dll");
+ Generate ();
+ Assertion.AssertEquals ("", Code);
+ }
+ */
+ }
+}
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+
+ ///
+ /// <summary>
+ /// Test ICodeGenerator's GenerateCodeFromNamespace, along with a
+ /// minimal set CodeDom components.
+ /// </summary>
+ ///
+ [TestFixture]
+ public class CodeGeneratorFromNamespaceTest : CodeGeneratorTestBase
+ {
+ CodeNamespace codeNamespace = null;
+
+ [SetUp]
+ public void Init ()
+ {
+ InitBase ();
+ codeNamespace = new CodeNamespace ();
+ }
+
+ protected override void Generate ()
+ {
+ generator.GenerateCodeFromNamespace (codeNamespace, writer, options);
+ writer.Close ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void NullNamespaceTest ()
+ {
+ codeNamespace = null;
+ Generate ();
+ }
+
+ [Test]
+ public void NullNamespaceNameTest ()
+ {
+ codeNamespace.Name = null;
+ Generate ();
+ Assertion.AssertEquals ("\n", Code);
+ }
+
+
+ [Test]
+ public void DefaultNamespaceTest ()
+ {
+ Generate ();
+ Assertion.AssertEquals ("\n", Code);
+ }
+
+ [Test]
+ [Ignore ("This only differs in 4 spaces")]
+ public void SimpleNamespaceTest ()
+ {
+ codeNamespace.Name = "A";
+ Generate();
+ Assertion.AssertEquals ("namespace A {\n \n}\n", Code);
+ }
+
+ [Test]
+ [Ignore ("This only differs in 4 spaces")]
+ public void InvalidNamespaceTest ()
+ {
+ codeNamespace.Name = "A,B";
+ Generate();
+ Assertion.AssertEquals ("namespace A,B {\n \n}\n", Code);
+ }
+
+
+ [Test]
+ public void CommentOnlyNamespaceTest ()
+ {
+ CodeCommentStatement comment = new CodeCommentStatement ("a");
+ codeNamespace.Comments.Add (comment);
+ Generate ();
+ Assertion.AssertEquals ("// a\n\n", Code);
+ }
+ }
+
+ // FIXME implement tests for these methods:
+ // GenerateCodeFromType
+ // GenerateCodeFromExpression
+ // GenerateCodeFromStatement
+
+}
+
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+ ///
+ /// <summary>
+ /// Test ICodeGenerator's GenerateCodeFromStatement, along with a
+ /// minimal set CodeDom components.
+ /// </summary>
+ ///
+ [TestFixture]
+ public class CodeGeneratorFromStatementTest: CodeGeneratorTestBase
+ {
+ CodeStatement statement = null;
+
+ [SetUp]
+ public void Init ()
+ {
+ InitBase ();
+ statement = new CodeStatement ();
+ }
+
+ protected override void Generate ()
+ {
+ generator.GenerateCodeFromStatement (statement, writer, options);
+ writer.Close ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void DefaultStatementTest ()
+ {
+ Generate ();
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void NullStatementTest ()
+ {
+ statement = null;
+ Generate ();
+ }
+
+ [Test]
+ public void DefaultCodeCommentStatementTest ()
+ {
+ CodeCommentStatement commentStatement = new CodeCommentStatement ();
+ CodeComment comment = new CodeComment ();
+
+ commentStatement.Comment = comment;
+ statement = commentStatement;
+
+ Generate ();
+ Assertion.AssertEquals ("// \n", Code);
+ }
+
+ [Test]
+ public void MultiLineCodeCommentStatementTest ()
+ {
+ CodeCommentStatement commentStatement = new CodeCommentStatement ();
+ CodeComment comment = new CodeComment ();
+
+ comment.Text = "a\nb";
+ commentStatement.Comment = comment;
+ statement = commentStatement;
+
+ Generate ();
+ Assertion.AssertEquals ("// a\n//b\n", Code);
+ }
+
+ [Test]
+ public void DefaultThrowExceptionStatementTest ()
+ {
+ CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
+
+ statement = throwStatement;
+
+ Generate ();
+ Assertion.AssertEquals ("throw;\n", Code);
+ }
+
+ /*
+ [Test]
+ public void ThrowExceptionStatementTest ()
+ {
+ CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
+ throwStatement.ToThrow = ... expression
+ statement = throwStatement ();
+
+ Generate();
+ Assertion.AssertEquals ("", Code);
+ }
+ */
+
+ /*
+ System.Object
+ System.CodeDom.CodeObject
+ System.CodeDom.CodeStatement
+ System.CodeDom.CodeAssignStatement
+ System.CodeDom.CodeAttachEventStatement
+ - System.CodeDom.CodeCommentStatement
+ System.CodeDom.CodeConditionStatement
+ System.CodeDom.CodeExpressionStatement
+ System.CodeDom.CodeGotoStatement
+ System.CodeDom.CodeIterationStatement
+ System.CodeDom.CodeLabeledStatement
+ System.CodeDom.CodeMethodReturnStatement
+ System.CodeDom.CodeRemoveEventStatement
+ System.CodeDom.CodeSnippetStatement
+ System.CodeDom.CodeThrowExceptionStatement
+ System.CodeDom.CodeTryCatchFinallyStatement
+ System.CodeDom.CodeVariableDeclarationStatement
+
+ */
+
+
+ /*
+ [Test]
+ public void ReferencedTest ()
+ {
+ codeUnit.ReferencedAssemblies.Add ("System.dll");
+ Generate ();
+ Assertion.AssertEquals ("", Code);
+ }
+ */
+ }
+}
+
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+ ///
+ /// <summary>
+ /// Test ICodeGenerator's GenerateCodeFromType, along with a
+ /// minimal set CodeDom components.
+ /// </summary>
+ ///
+ [TestFixture]
+ public class CodeGeneratorFromTypeTest: CodeGeneratorTestBase
+ {
+ CodeTypeDeclaration type = null;
+
+ [SetUp]
+ public void Init ()
+ {
+ InitBase ();
+ type = new CodeTypeDeclaration ();
+ }
+
+ protected override void Generate ()
+ {
+ generator.GenerateCodeFromType (type, writer, options);
+ writer.Close ();
+ }
+
+ [Test]
+ public void DefaultTypeTest ()
+ {
+ Generate ();
+ Assertion.AssertEquals ("public class {\n}\n", Code);
+ }
+
+ [Test]
+ [ExpectedException (typeof (NullReferenceException))]
+ public void NullTypeTest ()
+ {
+ type = null;
+ Generate ();
+ }
+
+ /*
+ [Test]
+ public void ReferencedTest ()
+ {
+ codeUnit.ReferencedAssemblies.Add ("System.dll");
+ Generate ();
+ Assertion.AssertEquals ("", Code);
+ }
+ */
+ }
+}
--- /dev/null
+//
+// Microsoft.CSharp.* Test Cases
+//
+// Authors:
+// Eric Lindvall (eric@5stops.com)
+//
+// (c) 2003 Eric Lindvall
+//
+using System;
+using System.IO;
+using System.Text;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using Microsoft.CSharp;
+
+using NUnit.Framework;
+
+namespace MonoTests.Microsoft.CSharp
+{
+ ///
+ /// <summary>
+ /// Base test for a variety of CodeGenerator GenerateCodeXXX methods.
+ ///
+ /// This testing is a form of hybrid test, it tests the variety of CodeDom
+ /// classes as well as the C# code generator.
+ ///
+ /// The implementations bellow provide a template as well as guidlines for
+ /// implementing further tests.
+ /// </summary>
+ ///
+ public abstract class CodeGeneratorTestBase
+ {
+ CodeDomProvider provider = null;
+ protected ICodeGenerator generator = null;
+ protected CodeGeneratorOptions options = null;
+ protected StringWriter writer = null;
+
+ public void InitBase()
+ {
+ provider = new CSharpCodeProvider ();
+ generator = provider.CreateGenerator ();
+ options = new CodeGeneratorOptions ();
+ writer = new StringWriter ();
+
+ writer.NewLine = "\n";
+ }
+
+ protected virtual string Code {
+ get { return writer.ToString (); }
+ }
+
+ protected abstract void Generate ();
+ }
+}
+Microsoft.CSharp/CodeGeneratorFromCompileUnitTest.cs
+Microsoft.CSharp/CodeGeneratorFromExpressionTest.cs
+Microsoft.CSharp/CodeGeneratorFromNamespaceTest.cs
+Microsoft.CSharp/CodeGeneratorFromStatementTest.cs
+Microsoft.CSharp/CodeGeneratorFromTypeTest.cs
+Microsoft.CSharp/CodeGeneratorTestBase.cs
System/UriBuilderTest.cs
System/UriTest.cs
System.Collections.Specialized/BasicOperationsTest.cs
System.Text.RegularExpressions/PerlTest.cs
System.Text.RegularExpressions/PerlTrials.cs
System.Text.RegularExpressions/RegexTrial.cs
-