Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,303 @@
2008-05-09 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests for
System.ParamArrayAttribute custom attribute.
2008-04-30 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests for static and abstract
property.
2008-03-13 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromCompileUnitTest.cs: Added ExternalSourceTest.
2008-01-27 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromExpressionTest.cs: Numbered tests. Fixed test for
DelegateInvokeExpression to pass on MS 2.0 and improved coverage.
2008-01-16 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromNamespaceTest.cs: Added tests for type parameters.
2007-12-21 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromTypeTest.cs: Added PartialTypeTest.
2007-10-30 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromExpressionTest.cs: Added ArrayIndexerExpressionTest.
2007-05-18 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromExpressionTest.cs: Added EventReferenceTest and DelegateInvokeTest.
* CodeGeneratorFromTypeTest.cs: Added DelegateWithParameterTest.
2007-05-17 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromExpressionTest.cs: Added EscapedIdentifierTest.
* CodeGeneratorFromStatementTest.cs: Added CodeAttachEventStatementKeywordTest.
2007-05-08 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CodeGeneratorFromExpressionTest.cs: Added ArrayCreateExpressionTest.
2007-04-13 Frederik Carlier <frederik.carlier@carlier-online.be>
* CodeGeneratorFromBinaryOperatorTest.cs: Regression test for bug 81372, test
for code generated when comparing against null (Nothing in Visual Basic)
2007-02-21 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Modified tests to also cover fix for bug
#80920. No longer use Assert class in separate AppDomain since it
will only work if nunit.framework assembly is in the GAC.
* CodeGeneratorFromTypeTest.cs: Fixed tests to pass on MS.
2007-02-21 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Mark tests that rely on vbnc as NotWorking,
and remove comment about mbas.
2006-10-22 Zoltan Varga <vargaz@gmail.com>
* VBCodeProviderTest.cs: Mark this as NotWorking since mbas is no more.
2006-08-08 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Modified tests to verify fix for bug
#78384, and check support for linked resources.
2006-04-20 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromNamespaceTest.cs: Added tests for
GenerateCodeFromNamespace.
2005-12-07 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromExpressionTest.cs: Added tests for
CodePrimitiveExpression.
2005-11-30 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromStatementTest.cs: Added tests for
CodeAssignStatement, CodeAttachEventStatement, CodeConditionStatement,
CodeExpressionStatement, CodeIterationStatement,
CodeLabeledStatement, CodeMethodReturnStatement,
CodeRemoveEventStatement and CodeSnippetStatement.
2005-11-26 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorTestBase.cs: Removed Code property, added Generate
overload taking CodeGeneratorOptions, added NewLine property.
* CodeGeneratorCompileUnitTest.cs: Use Generate method instead of
Code property.
* CodeGeneratorFromExpressionTest.cs: Added test for
CodeParameterDeclarationExpression.
* CodeGeneratorFromTypeTest.cs: Added tests for __exception name that
is output for zero-length field, event and parameter name in 2.0
profile.
* CodeGeneratorFromStatementTest.cs: Added.
2005-10-28 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests for CodeEntryPointMethod
and bug #76580.
2005-10-25 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorTestBase.cs: Set eol-style to native.
* VBCodeProviderTest.cs: Set eol-style to native.
* CodeGeneratorFromCompileUnitTest.cs: Modified test to check
output for CodeAttributeArgument with no name. Set eol-style to
native.
* CodeGeneratorFromExpressionTest.cs: Set eol-style to native.
* CodeGeneratorFromTypeTest.cs: Fixed line endings. Set eol-style to
native.
2005-10-24 Raja R Harinath <harinath@gmail.com>
* CodeGeneratorFromTypeTest.cs (CodeGeneratorFromTypeTest_Class)
(CodeGeneratorFromTypeTest_Struct): Update to reflect mbas workaround.
2005-10-17 Sebastien Pouliot <sebastien@ximian.com>
* VBCodeProviderCas.cs: New. CAS unit tests.
2005-10-15 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Reworked tests to pass
CodeGeneratorOptions to Generate* methods.
2005-09-12 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Re-enabled CreateCompiler test as bug #75223
is fixed.
2005-07-30 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added NewSlot tests.
2005-07-24 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added BaseTypes and TypeConstructor
tests. Enabled enum, interface and delegate tests.
2005-07-21 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Inherit from
System.CodeDom.CodeGeneratorFromTypeTestBase. Added testfixture
for testing enum, interface and delegate, but for now these are
marked NotWorking.
2005-07-02 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added test for
ReturnTypeCustomAttributes.
2005-07-02 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Modified test to ensure that scope
modifiers are not output for events.
2005-07-02 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added PrivateImplementationType tests
for property, event, method. Added Overloads tests for property and
method.
2005-07-01 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added ImplementationTypes tests for
property, event, method, ctor.
2005-06-30 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added property indexer and
parameter tests.
2005-06-28 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromExpressionTest.cs: Renumbered tests for
TypeReferenceExpressionTest. Added tests for zero-length or null
type name, and object type.
2005-06-27 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromExpressionTest.cs: Added tests for
GenerateCodeFromExpression.
2005-06-26 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Make tests pass on MS.NET 1.x and 2.0,
and Mono (1.0/2.0).
2005-06-26 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests for ctor level attributes
and Base/Chained ctor args.
2005-06-26 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromCompileUnitTest.cs: Removed last usage of
Assertion class.
* CodeGeneratorFromTypeTest.cs: Added tests for method, property and
parameter level attributes.
2005-06-25 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromCompileUnitTest.cs: Added test for assembly-level
attribute without value. Use Assert instead of deprecated Assertion.
* CodeGeneratorFromTypeTest.cs: Use Assert instead of Assertion.
2005-06-25 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests to verify code generated
for field and event members.
2005-06-25 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromTypeTest.cs: Added tests to verify code generated
for Type (with and without custom attributes).
2005-06-25 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGeneratorFromCompileUnitTest.cs: several tests to ensure
code generated by GenerateCodeFromCompileUnit matches that of
MS.NET.
2005-06-12 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Marked tests NotWorking on 2.0 profile
as we don't yet have an mbas for that profile.
2005-06-12 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: fixed line endings
2005-06-10 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: improve reporting of test failures as a
result of compile errors. Added a ICodeGenerator.Supports tests
for .NET 2.0.
2005-06-10 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: removed unnecessary test, added test
for ICodeGenerator.Supports.
2005-06-09 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: added batch of tests that check whether
temporary files are cleaned up, compile multiple sources/compile units
and files. Use separate AppDomain for tests that actually loaded
the compiled assembly, to ensure no test output is left on the system.
2005-06-05 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: moved to using NUnit 2.x Assert, improve
failure output of CreateCompiler test.
2005-05-30 Gert Driesen <drieseng@users.sourceforge.net>
* VBCodeProviderTest.cs: Added tests for GenerateInMemory
compiler parameter.
2004-12-03 Raja R Harinath <rharinath@novell.com>
* VBCodeProviderTest.cs: Change namespace to
MonoTests.Microsoft.VisualBasic.
2004-11-19 Raja R Harinath <rharinath@novell.com>
* VBCodeProviderTest.cs (CreateCompiler): Be more verbose about
error exit.
2004-03-08 Nick Drochak <ndrochak@ieee.org>
* VBCodeProviderTest.cs: On windows, do not use mono to execute
assembly. Actually, this should be if running on MS's CLR, but
for now it will do.
2004-02-04 Jackson Harper <jackson@ximian.com>
* VBCodeProviderTest.cs: Use mono to execute assembly.
2003-12-11 Nick Drochak <ndrochak@ieee.org>
* VBCodeProviderTest.cs: Console.WriteLine's don't really belong in
unit tests.
2003-12-11 Nick Drochak <ndrochak@ieee.org>
* VBCodeProviderTest.cs: Fixed subtle namespace issues preventing
build with csc.
2003-12-10 Jochen Wezel <jwezel@compumaster.de>
* VBCodeProviderTest.cs: moved into proper subdir
and also extended for additional testings
* CodeGenerator*.cs: C# units copied and changed for VB use

View File

@@ -0,0 +1,80 @@
//
// Microsoft.VisualBasic.* Test Cases
//
// Authors:
// Frederik Carlier <frederik.carlier@carlier-online.be>
// Rolf Bjarne Kvinge <RKvinge@novell.com>
//
// (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 CodeGeneratorFromBinaryOperatorTest
{
VBCodeProvider provider;
ICodeGenerator generator;
CodeGeneratorOptions options;
[SetUp]
public void SetUp ()
{
provider = new VBCodeProvider ();
generator = provider.CreateGenerator ();
options = new CodeGeneratorOptions ();
}
[Test]
public void TypeReferenceExpressionTest ()
{
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter (sb)) {
CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
CodeFieldReferenceExpression parentField = new CodeFieldReferenceExpression();
parentField.TargetObject = thisRef;
parentField.FieldName = "Parent";
CodeBinaryOperatorExpression expression = new CodeBinaryOperatorExpression(
parentField,
CodeBinaryOperatorType.IdentityInequality,
new CodePrimitiveExpression(null));
Assert.AreEqual ("(Not (Me.Parent) Is Nothing)", Generate (expression, sw), "#1");
sw.Close ();
}
sb = new StringBuilder();
using (StringWriter sw = new StringWriter (sb)) {
CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
CodeFieldReferenceExpression parentField = new CodeFieldReferenceExpression();
parentField.TargetObject = thisRef;
parentField.FieldName = "Parent";
CodeBinaryOperatorExpression expression = new CodeBinaryOperatorExpression(
new CodePrimitiveExpression(null),
CodeBinaryOperatorType.IdentityInequality,
parentField);
Assert.AreEqual ("(Not (Me.Parent) Is Nothing)", Generate (expression, sw), "#2");
sw.Close ();
}
}
private string Generate (CodeExpression expression, StringWriter sw)
{
generator.GenerateCodeFromExpression (expression, sw, options);
return sw.ToString ();
}
}
}

View File

@@ -0,0 +1,199 @@
//
// Microsoft.VisualBasic.* Test Cases
//
// Authors:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (c) 2005 Novell
//
using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.CodeDom;
using System.CodeDom.Compiler;
using NUnit.Framework;
namespace MonoTests.Microsoft.VisualBasic
{
[TestFixture]
public class CodeGeneratorFromCompileUnitTest : CodeGeneratorTestBase
{
string codeUnitHeader = "";
CodeCompileUnit codeUnit = null;
public CodeGeneratorFromCompileUnitTest ()
{
Init();
codeUnitHeader = Generate ();
}
[SetUp]
public void Init ()
{
InitBase ();
codeUnit = new CodeCompileUnit ();
}
protected override string Generate (CodeGeneratorOptions options)
{
StringWriter writer = new StringWriter ();
writer.NewLine = NewLine;
generator.GenerateCodeFromCompileUnit (codeUnit, writer, options);
writer.Close ();
return writer.ToString ().Substring (codeUnitHeader.Length);
}
[Test]
public void DefaultCodeUnitTest ()
{
Assert.AreEqual ("", Generate ());
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void NullCodeUnitTest ()
{
codeUnit = null;
Generate();
}
[Test]
public void ReferencedTest ()
{
codeUnit.ReferencedAssemblies.Add ("System.dll");
Assert.AreEqual ("", Generate ());
}
[Test]
public void SimpleNamespaceTest ()
{
CodeNamespace ns = new CodeNamespace ("A");
codeUnit.Namespaces.Add (ns);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}Namespace A{0}End Namespace{0}", NewLine), Generate ());
}
[Test]
public void ReferenceAndSimpleNamespaceTest()
{
CodeNamespace ns = new CodeNamespace ("A");
codeUnit.Namespaces.Add (ns);
codeUnit.ReferencedAssemblies.Add ("using System;");
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}Namespace A{0}End Namespace{0}", NewLine), Generate ());
}
[Test]
public void SimpleAttributeTest ()
{
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"<Assembly: A()> {0}", NewLine), Generate ());
}
[Test]
public void AttributeWithValueTest ()
{
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
attrDec.Arguments.Add (new CodeAttributeArgument("A1",
new CodePrimitiveExpression(false)));
attrDec.Arguments.Add (new CodeAttributeArgument("A2",
new CodePrimitiveExpression(true)));
// null name should not be output
attrDec.Arguments.Add (new CodeAttributeArgument (null,
new CodePrimitiveExpression (true)));
// zero length name should not be output
attrDec.Arguments.Add (new CodeAttributeArgument (string.Empty,
new CodePrimitiveExpression (false)));
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual ("<Assembly: A(A1:=false, A2:=true, true, false)> " +
NewLine, Generate ());
}
[Test]
public void MultipleAttributeTest ()
{
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "B";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"<Assembly: A(), _{0} Assembly: B()> {0}", NewLine),
Generate ());
}
[Test]
public void AttributeAndSimpleNamespaceTest ()
{
CodeNamespace ns = new CodeNamespace ("A");
codeUnit.Namespaces.Add (ns);
CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "A";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
attrDec = new CodeAttributeDeclaration ();
attrDec.Name = "B";
codeUnit.AssemblyCustomAttributes.Add (attrDec);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"<Assembly: A(), _{0} Assembly: B()> {0}{0}Namespace A{0}End "
+ "Namespace{0}", NewLine), Generate ());
}
[Test]
public void CodeSnippetTest ()
{
StringBuilder sb = new StringBuilder();
sb.Append ("Public Class Test1");
sb.Append (Environment.NewLine);
sb.Append ("End Class");
StringWriter writer = new StringWriter ();
writer.NewLine = NewLine;
codeUnit = new CodeSnippetCompileUnit (sb.ToString ());
generator.GenerateCodeFromCompileUnit (codeUnit, writer, options);
writer.Close ();
Assert.AreEqual (sb.ToString () + NewLine, writer.ToString());
}
[Test]
public void ExternalSourceTest ()
{
CodeSnippetCompileUnit snippet;
StringBuilder sb = new StringBuilder();
sb.Append ("\n");
sb.Append ("#ExternalSource(\"file.vb\",123)");
sb.Append ("\n");
sb.Append ("\n");
sb.Append ("\n");
sb.Append ("#End ExternalSource");
sb.Append ("\n");
StringWriter writer = new StringWriter ();
writer.NewLine = NewLine;
codeUnit = new CodeSnippetCompileUnit ("");
snippet = (CodeSnippetCompileUnit) codeUnit;
snippet.LinePragma = new CodeLinePragma ("file.vb", 123);
generator.GenerateCodeFromCompileUnit (codeUnit, writer, options);
writer.Close ();
Assert.AreEqual (sb.ToString (), writer.ToString());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,483 @@
//
// Microsoft.VisualBasic.* Test Cases
//
// Authors:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (c) 2006 Novell
//
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Globalization;
using System.IO;
using System.Text;
using NUnit.Framework;
namespace MonoTests.Microsoft.VisualBasic
{
/// <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 string Generate (CodeGeneratorOptions options)
{
StringWriter writer = new StringWriter ();
writer.NewLine = NewLine;
generator.GenerateCodeFromNamespace (codeNamespace, writer, options);
writer.Close ();
return writer.ToString ();
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void NullNamespaceTest ()
{
codeNamespace = null;
Generate ();
}
[Test]
public void NullNamespaceNameTest ()
{
codeNamespace.Name = null;
Assert.AreEqual ("\n", Generate ());
}
[Test]
public void DefaultNamespaceTest ()
{
Assert.AreEqual ("\n", Generate ());
}
[Test]
public void SimpleNamespaceTest ()
{
codeNamespace.Name = "A";
Assert.AreEqual ("\nNamespace A\nEnd Namespace\n", Generate ());
}
[Test]
public void InvalidNamespaceTest ()
{
codeNamespace.Name = "A,B";
Assert.AreEqual ("\nNamespace A,B\nEnd Namespace\n", Generate ());
}
[Test]
public void CommentOnlyNamespaceTest ()
{
CodeCommentStatement comment = new CodeCommentStatement ("a");
codeNamespace.Comments.Add (comment);
Assert.AreEqual ("\n'a\n", Generate ());
}
[Test]
public void ImportsTest ()
{
codeNamespace.Imports.Add (new CodeNamespaceImport ("System"));
codeNamespace.Imports.Add (new CodeNamespaceImport ("System.Collections"));
Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
"Imports System{0}" +
"Imports System.Collections{0}" +
"{0}", NewLine), Generate (), "#1");
codeNamespace.Name = "A";
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"Imports System{0}" +
"Imports System.Collections{0}" +
"{0}" +
"Namespace A{0}" +
"End Namespace{0}", NewLine), Generate (), "#2");
codeNamespace.Name = null;
codeNamespace.Comments.Add (new CodeCommentStatement ("a"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"Imports System{0}" +
"Imports System.Collections{0}" +
"{0}" +
"'a{0}", NewLine), Generate (), "#3");
codeNamespace.Name = "A";
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"Imports System{0}" +
"Imports System.Collections{0}" +
"{0}" +
"'a{0}" +
"Namespace A{0}" +
"End Namespace{0}", NewLine), Generate (), "#4");
}
[Test]
public void TypeTest ()
{
codeNamespace.Types.Add (new CodeTypeDeclaration ("Person"));
Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
"Public Class Person{0}" +
"End Class{0}", NewLine), Generate (), "#A1");
CodeGeneratorOptions options = new CodeGeneratorOptions ();
options.BlankLinesBetweenMembers = false;
Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
"{0}" +
"Public Class Person{0}" +
"End Class{0}", NewLine), Generate (options), "#A2");
codeNamespace.Name = "A";
Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
"{0}" +
"Namespace A{0}" +
" {0}" +
" Public Class Person{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#B1");
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace A{0}" +
" Public Class Person{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (options), "#B2");
}
#if NET_2_0
[Test]
public void Type_TypeParameters ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
type.TypeParameters.Add (new CodeTypeParameter ("T"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#1");
type.TypeParameters.Add (new CodeTypeParameter ("As"));
type.TypeParameters.Add (new CodeTypeParameter ("New"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T, As, New){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#2");
CodeTypeParameter typeParamR = new CodeTypeParameter ("R");
typeParamR.Constraints.Add (new CodeTypeReference (typeof (IComparable)));
type.TypeParameters.Add (typeParamR);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T, As, New, R As System.IComparable){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#3");
type.TypeParameters.Add (new CodeTypeParameter ("S"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T, As, New, R As System.IComparable, S){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#4");
}
[Test]
public void Type_TypeParameters_Constraints ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
CodeTypeParameter typeParamT = new CodeTypeParameter ("T");
typeParamT.Constraints.Add (new CodeTypeReference (typeof (IComparable)));
type.TypeParameters.Add (typeParamT);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As System.IComparable){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#1");
typeParamT.Constraints.Add (new CodeTypeReference (typeof (ICloneable)));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As {{System.IComparable, System.ICloneable}}){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#2");
typeParamT.HasConstructorConstraint = true;
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As {{System.IComparable, System.ICloneable, New}}){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#3");
CodeTypeParameter typeParamS = new CodeTypeParameter ("S");
typeParamS.Constraints.Add (new CodeTypeReference (typeof (IDisposable)));
type.TypeParameters.Add (typeParamS);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As {{System.IComparable, System.ICloneable, New}}, S As System.IDisposable){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#4");
CodeTypeParameter typeParamR = new CodeTypeParameter ("R");
typeParamR.HasConstructorConstraint = true;
type.TypeParameters.Add (typeParamR);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As {{System.IComparable, System.ICloneable, New}}, S As System.IDisposable, R As New){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#5");
}
[Test]
public void Type_TypeParameters_ConstructorConstraint ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
CodeTypeParameter typeParam = new CodeTypeParameter ("T");
typeParam.HasConstructorConstraint = true;
type.TypeParameters.Add (typeParam);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass(Of T As New){0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate ());
}
[Test]
public void Method_TypeParameters ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
CodeMemberMethod method = new CodeMemberMethod ();
method.Name = "SomeMethod";
type.Members.Add (method);
method.TypeParameters.Add (new CodeTypeParameter ("T"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#1");
method.TypeParameters.Add (new CodeTypeParameter ("As"));
method.TypeParameters.Add (new CodeTypeParameter ("New"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T, As, New)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#2");
CodeTypeParameter typeParamR = new CodeTypeParameter ("R");
typeParamR.Constraints.Add (new CodeTypeReference (typeof (IComparable)));
method.TypeParameters.Add (typeParamR);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T, As, New, R As System.IComparable)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#3");
method.TypeParameters.Add (new CodeTypeParameter ("S"));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T, As, New, R As System.IComparable, S)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#4");
}
[Test]
public void Method_TypeParameters_Constraints ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
CodeMemberMethod method = new CodeMemberMethod ();
method.Name = "SomeMethod";
type.Members.Add (method);
CodeTypeParameter typeParamT = new CodeTypeParameter ("T");
typeParamT.Constraints.Add (new CodeTypeReference (typeof (IComparable)));
method.TypeParameters.Add (typeParamT);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As System.IComparable)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#1");
typeParamT.Constraints.Add (new CodeTypeReference (typeof (ICloneable)));
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As {{System.IComparable, System.ICloneable}})(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#2");
typeParamT.HasConstructorConstraint = true;
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As {{System.IComparable, System.ICloneable, New}})(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#3");
CodeTypeParameter typeParamS = new CodeTypeParameter ("S");
typeParamS.Constraints.Add (new CodeTypeReference (typeof (IDisposable)));
method.TypeParameters.Add (typeParamS);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As {{System.IComparable, System.ICloneable, New}}, S As System.IDisposable)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#4");
CodeTypeParameter typeParamR = new CodeTypeParameter ("R");
typeParamR.HasConstructorConstraint = true;
method.TypeParameters.Add (typeParamR);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As {{System.IComparable, System.ICloneable, New}}, S As System.IDisposable, R As New)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate (), "#5");
}
[Test]
public void Method_TypeParameters_ConstructorConstraint ()
{
codeNamespace.Name = "SomeNS";
CodeTypeDeclaration type = new CodeTypeDeclaration ("SomeClass");
codeNamespace.Types.Add (type);
CodeMemberMethod method = new CodeMemberMethod ();
method.Name = "SomeMethod";
type.Members.Add (method);
CodeTypeParameter typeParam = new CodeTypeParameter ("T");
typeParam.HasConstructorConstraint = true;
method.TypeParameters.Add (typeParam);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"Namespace SomeNS{0}" +
" {0}" +
" Public Class SomeClass{0}" +
" {0}" +
" Private Sub SomeMethod(Of T As New)(){0}" +
" End Sub{0}" +
" End Class{0}" +
"End Namespace{0}", NewLine), Generate ());
}
#endif
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
207bb9f47864178e6c88bf4d5a4dd313bed99f8e

View File

@@ -0,0 +1,59 @@
//
// Microsoft.VisualBasic.* Test Cases
//
// Authors:
// Jochen Wezel (jwezel@compumaster.de)
//
// Based on the C# units of
// Erik LeBel (eriklebel@yahoo.ca)
//
// (c) 2003 Jochen Wezel, CompuMaster GmbH
//
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
{
///
/// <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 VB 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;
public void InitBase()
{
provider = new VBCodeProvider ();
generator = provider.CreateGenerator ();
options = new CodeGeneratorOptions ();
}
protected string Generate ()
{
return Generate (options);
}
protected virtual string NewLine
{
get { return "\n"; }
}
protected abstract string Generate (CodeGeneratorOptions options);
}
}

View File

@@ -0,0 +1,119 @@
//
// VBCodeProviderCas.cs
// - CAS unit tests for Microsoft.VisualBasic.VBCodeProvider
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using NUnit.Framework;
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using Microsoft.VisualBasic;
namespace MonoCasTests.Microsoft.VisualBasic {
[TestFixture]
[Category ("CAS")]
public class VBCodeProviderCas {
[SetUp]
public virtual void SetUp ()
{
if (!SecurityManager.SecurityEnabled)
Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void Deny_Unrestricted ()
{
VBCodeProvider vbprov = new VBCodeProvider ();
Assert.AreEqual ("vb", vbprov.FileExtension, "FileExtension");
Assert.AreEqual (LanguageOptions.CaseInsensitive, vbprov.LanguageOptions, "LanguageOptions");
Assert.IsNotNull (vbprov.CreateCompiler (), "CreateCompiler");
Assert.IsNotNull (vbprov.CreateGenerator (), "CreateGenerator");
try {
Assert.IsNotNull (vbprov.GetConverter (typeof (string)), "GetConverter");
}
catch (NotImplementedException) {
// mono
}
#if NET_2_0
CodeTypeMember ctm = new CodeTypeMember ();
StringWriter sw = new StringWriter ();
CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
try {
vbprov.GenerateCodeFromMember (ctm, sw, cgo);
}
catch (NotImplementedException) {
// mono
}
#endif
}
// LinkDemand
// we use reflection to call this class as it is protected by a LinkDemand
// (which will be converted into full demand, i.e. a stack walk) when
// reflection is used (i.e. it gets testable).
public virtual object Create ()
{
ConstructorInfo ci = typeof (VBCodeProvider).GetConstructor (new Type[0]);
Assert.IsNotNull (ci, "default .ctor");
return ci.Invoke (null);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
[ExpectedException (typeof (SecurityException))]
public void LinkDemand_Deny_Unrestricted ()
{
Assert.IsNotNull (Create ());
}
[Test]
[EnvironmentPermission (SecurityAction.Deny, Read = "MONO")]
[ExpectedException (typeof (SecurityException))]
public void LinkDemand_Deny_Anything ()
{
// denying any permissions -> not full trust!
Assert.IsNotNull (Create ());
}
[Test]
[PermissionSet (SecurityAction.PermitOnly, Unrestricted = true)]
public void LinkDemand_PermitOnly_Unrestricted ()
{
Assert.IsNotNull (Create ());
}
}
}

File diff suppressed because it is too large Load Diff