Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@@ -8,7 +8,7 @@ using Mono;
using NUnit.Framework.SyntaxHelpers;
#endif
namespace MonoTests {
namespace MonoTests.Mono {
[TestFixture]
public class DataConverterTest
@@ -50,9 +50,9 @@ namespace MonoTests {
[Test]
public void StringAlignment ()
{
byte[] packed = Mono.DataConverter.Pack ("bz8", 1, TEST_STRING);
byte[] packed = global::Mono.DataConverter.Pack ("bz8", 1, TEST_STRING);
IList unpacked = Mono.DataConverter.Unpack ("bz8", packed, 0);
IList unpacked = global::Mono.DataConverter.Unpack ("bz8", packed, 0);
Assert.AreEqual(1, (byte) unpacked[0]);
Assert.AreEqual(TEST_STRING, new string((char[]) unpacked[1]));
@@ -65,4 +65,4 @@ namespace MonoTests {
Assert.That ((f - 3.14f), Is.LessThanOrEqualTo (Single.Epsilon));
}
}
}
}

View File

@@ -3,6 +3,7 @@
// (C) 2002 Ulrich Kunitz
//
using System.Collections.Generic;
using NUnit.Framework;
using System;
using System.Globalization;
@@ -797,6 +798,44 @@ public class CalendarTest {
Assert.AreEqual (4363, kc.ToFourDigitYear (4363), "#4-4");
}
public void TestDaysInYear (Calendar calendar, int year)
{
var daysInYear = calendar.GetDaysInYear (year);
var daysInMonths = 0;
var monthInYear = calendar.GetMonthsInYear (year);
for (var m = 1; m <= monthInYear; m++)
daysInMonths += calendar.GetDaysInMonth (year, m);
Assert.AreEqual (daysInYear, daysInMonths, string.Format("Calendar:{0} Year:{1}",calendar.GetType(), year));
}
[Test]
public void DaysInYear ()
{
var calendars = new List<Calendar> (acal) {
new UmAlQuraCalendar ()
};
foreach (var calendar in calendars) {
var minYear = calendar.GetYear (calendar.MinSupportedDateTime);
var maxYear = calendar.GetYear (calendar.MaxSupportedDateTime) - 1 ;
var midYear = calendar.GetYear (DateTime.Now);
var yearsTested = Math.Min (1000, (maxYear - minYear) / 2);
midYear -= yearsTested / 2;
int y1 = minYear, y2 = maxYear, y3 = midYear;
for (var i = 0; i < yearsTested; i++) {
TestDaysInYear (calendar, y1);
TestDaysInYear (calendar, y2);
if (y3 > minYear && y3 < maxYear)
TestDaysInYear (calendar, y3);
y1++; y2--; y3++;
}
}
}
// TODO: more tests :-)
} // class CalendarTest

View File

@@ -10,6 +10,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
@@ -1059,6 +1060,23 @@ namespace MonoTests.System.IO
Assert.AreEqual (TempFolder + DSC + "ToString.Test", info.ToString ());
}
#if NET_4_0
[Test]
public void EnumerateFileSystemInfosTest ()
{
var dirInfo = new DirectoryInfo (TempFolder);
dirInfo.CreateSubdirectory ("1").CreateSubdirectory ("a");
dirInfo.CreateSubdirectory ("2").CreateSubdirectory ("b");
var l = new List<string> ();
foreach (var info in dirInfo.EnumerateFileSystemInfos ("*", SearchOption.AllDirectories))
l.Add (info.Name);
l.Sort ();
Assert.AreEqual ("1,2,a,b", string.Join (",", l), "#1");
}
#endif
#if !MOBILE
[Test]
public void Serialization ()
@@ -1111,7 +1129,7 @@ namespace MonoTests.System.IO
try {
Directory.CreateDirectory (path);
Directory.CreateDirectory (dir);
Mono.Unix.UnixSymbolicLinkInfo li = new Mono.Unix.UnixSymbolicLinkInfo (link);
global::Mono.Unix.UnixSymbolicLinkInfo li = new global::Mono.Unix.UnixSymbolicLinkInfo (link);
li.CreateSymbolicLinkTo (dir);
DirectoryInfo info = new DirectoryInfo (path);

View File

@@ -374,11 +374,11 @@ public class DirectoryTest
string path = TempFolder + DSC + "ExistsAccessDenied";
Directory.CreateDirectory (path);
Mono.Posix.Syscall.chmod (path, 0);
global::Mono.Posix.Syscall.chmod (path, 0);
try {
Assert.IsFalse (Directory.Exists(path + DSC + "b"));
} finally {
Mono.Posix.Syscall.chmod (path, (Mono.Posix.FileMode) 755);
global::Mono.Posix.Syscall.chmod (path, (global::Mono.Posix.FileMode) 755);
Directory.Delete (path);
}
}

View File

@@ -317,10 +317,12 @@ namespace MonoTests.System.Reflection.Emit
m1.Invoke(null, new object[] { 5 });
}
// Disabl known warning, the Field is never used directly from C#
#pragma warning disable 414
class Host {
static string Field = "foo";
}
#pragma warning restore 414
[Test]
[Category ("NotDotNet")] // https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=297416
public void TestOwnerMemberAccess ()

View File

@@ -27,7 +27,6 @@ namespace MonoTests.System.Reflection.Emit
{
AssemblyBuilder assembly;
ModuleBuilder module;
int typeCount;
static string ASSEMBLY_NAME = "MonoTests.System.Reflection.Emit.TypeBuilderTest";
[SetUp]
@@ -46,7 +45,6 @@ namespace MonoTests.System.Reflection.Emit
assemblyName, mode, Path.GetTempPath ());
module = assembly.DefineDynamicModule ("module1");
typeCount = 0;
}
[Test]

View File

@@ -1 +1 @@
382f3f255279b48e53d7e85bf3b9d869cbf2488c
b1b7cf320f3f5346dd7e01ef4551018929f2d874

View File

@@ -42,7 +42,6 @@ namespace MonoCasTests.System.Reflection {
public class AssemblyNameCas {
private MonoTests.System.Reflection.AssemblyNameTest ant;
private AssemblyName main;
[TestFixtureSetUp]
public void FixtureSetUp ()

View File

@@ -73,6 +73,8 @@ namespace MonoTests.System.Reflection
{
}
// Disable this warning, as the purpose of this struct is to poke at the internal via reflection
#pragma warning disable 649
class FieldInvokeMatrix
{
public Byte field_Byte;
@@ -102,6 +104,7 @@ namespace MonoTests.System.Reflection
public Int64Enum field_Int64Enum;
public UInt64Enum field_UInt64Enum;
}
#pragma warning restore 649
public enum ByteEnum : byte
{
@@ -376,10 +379,13 @@ namespace MonoTests.System.Reflection
Assert.AreEqual (typeof (Marshal1), Type.GetType (attr.MarshalType), "#I4");
}
// Disable "field not used warning", this is intended.
#pragma warning disable 649
class Foo {
public static int static_field;
public int field;
}
#pragma warning restore 649
[ExpectedException (typeof (ArgumentException))]
public void GetValueWrongObject ()
@@ -1359,16 +1365,24 @@ namespace MonoTests.System.Reflection
}
// We do not refernece the field, that is expected
#pragma warning disable 169
// Helper classes
class RefOnlyFieldClass
{
// Helper property
static int RefOnlyField;
}
#pragma warning restore 169
class NonPublicFieldClass
{
protected int protectedField;
public void Dummy ()
{
protectedField = 1;
}
}
public class FieldInfoTest<T>

View File

@@ -42,9 +42,12 @@ using System.Collections.Generic;
#endif
namespace A.B.C {
// Disable expected warning
#pragma warning disable 169
public struct MethodInfoTestStruct {
int p;
}
#pragma warning restore 169
}
namespace MonoTests.System.Reflection
{
@@ -253,7 +256,7 @@ namespace MonoTests.System.Reflection
public struct SimpleStruct
{
int a;
public int a;
}
public static unsafe SimpleStruct* PtrFunc2 (SimpleStruct* a, A.B.C.MethodInfoTestStruct *b)

View File

@@ -178,7 +178,7 @@ namespace MonoTests.System.Reflection.Emit
}
public class Bar<T> {
public class Foo<T> {}
public class Foo<U> {}
}
[Test]

View File

@@ -29,6 +29,8 @@ using System;
using System.Reflection;
using NUnit.Framework;
// Various fields in this class are not used directly by the C# code, they are only here to be reflected upon
#pragma warning disable 649
namespace MonoTests.System.Reflection
{
[TestFixture]

View File

@@ -402,9 +402,12 @@ namespace MonoTests.System.Runtime.CompilerServices {
static int reachable = 0;
public class FinalizableLink {
// The sole purpose of this object is to keep a reference to another object, so it is fine to not use it.
#pragma warning disable 414
object obj;
ConditionalWeakTable <object,object> cwt;
int id;
#pragma warning restore 414
ConditionalWeakTable <object,object> cwt;
public FinalizableLink (int id, object obj, ConditionalWeakTable <object,object> cwt) {
this.id = id;

View File

@@ -94,8 +94,10 @@ namespace MonoTests.System.Runtime.CompilerServices {
RuntimeHelpers.RunClassConstructor (rth);
}
// Expected the handle here is that way, because we are going to test for an ArgumentException being thrown
#pragma warning disable 649
static RuntimeTypeHandle handle;
#pragma warning restore 649
[Test]
[ExpectedException (typeof (ArgumentException))]
public void RunClassConstructor_Uninitialized ()
@@ -122,7 +124,11 @@ namespace MonoTests.System.Runtime.CompilerServices {
}
static RuntimeFieldHandle rfh = typeof (Fielder).GetField ("array").FieldHandle;
// Disable expected warning: the point of the test is to validate that an exception is thrown for something with a null (the default value in this case)
#pragma warning disable 649
static RuntimeFieldHandle static_rfh;
#pragma warning restore 649
[Test]
[ExpectedException (typeof (ArgumentNullException))]

View File

@@ -72,6 +72,11 @@ namespace MonoTests.System.Runtime.CompilerServices
Interlocked.Increment (ref ic);
return false;
}
public override string ToString ()
{
return "Scheduler-" + name;
}
}
class SingleThreadSynchronizationContext : SynchronizationContext

View File

@@ -18,8 +18,11 @@ namespace MonoTests.System.Runtime.InteropServices
[TestFixture]
public class GCHandleTest
{
// Expected warning, the tests that reference this handle are testing for the default values of the object
#pragma warning disable 649
static GCHandle handle;
#pragma warning restore 649
[Test]
public void DefaultZeroValue_Allocated ()
{

View File

@@ -28,7 +28,7 @@ namespace MonoTests.System.Runtime.InteropServices
public int field;
}
class ClsNoLayout {
public class ClsNoLayout {
public int field;
}
@@ -173,12 +173,12 @@ namespace MonoTests.System.Runtime.InteropServices
Marshal.FreeHGlobal (ptr);
}
struct Foo {
int a;
static int b;
long c;
static char d;
int e;
public struct Foo {
public int a;
public static int b;
public long c;
public static char d;
public int e;
}
[Test]

View File

@@ -637,6 +637,8 @@ namespace MonoTests.System.Runtime.Serialization
Assert.AreEqual (_char, obj._char, context + "._char");
Assert.AreEqual (_dateTime, obj._dateTime, context + "._dateTime");
Assert.AreEqual (_decimal, obj._decimal, context + "._decimal");
Assert.AreEqual (_double, obj._double, context + "._double");
Assert.AreEqual (_short, obj._short, context = "._short");
Assert.AreEqual (_int, obj._int, context + "._int");
Assert.AreEqual (_long, obj._long, context + "._long");
Assert.AreEqual (_sbyte, obj._sbyte, context + "._sbyte");

View File

@@ -144,7 +144,6 @@ namespace MonoTests.System.Security.Cryptography {
Stream readStream;
Stream writeStream;
ICryptoTransform encryptor;
ICryptoTransform decryptor;
CryptoStream cs;
SymmetricAlgorithm aes;
@@ -156,7 +155,6 @@ namespace MonoTests.System.Security.Cryptography {
writeStream = new MemoryStream (new byte [0], true);
aes = SymmetricAlgorithm.Create ();
encryptor = aes.CreateEncryptor ();
decryptor = aes.CreateEncryptor ();
}
}

View File

@@ -28,6 +28,9 @@ namespace MonoTests.System.Security.Cryptography {
public class SelectableHmacSha384: HMAC {
// legacy parameter:
// http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
public SelectableHmacSha384 (byte[] key, bool legacy)
{
HashName = "SHA384";
@@ -45,7 +48,6 @@ namespace MonoTests.System.Security.Cryptography {
public class HMACSHA384Test : KeyedHashAlgorithmTest {
protected HMACSHA384 algo;
private bool legacy;
[SetUp]
public override void SetUp ()
@@ -53,8 +55,6 @@ namespace MonoTests.System.Security.Cryptography {
algo = new HMACSHA384 ();
algo.Key = new byte [8];
hash = algo;
// http://blogs.msdn.com/shawnfa/archive/2007/01/31/please-do-not-use-the-net-2-0-hmacsha512-and-hmacsha384-classes.aspx
legacy = (new HS384 ().BlockSize == 64);
}
// the hash algorithm only exists as a managed implementation

Some files were not shown because too many files have changed in this diff Show More