Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -514,7 +514,7 @@ namespace MonoTests.System {
null, null);
}
#if !MONOTOUCH && !FULL_AOT_RUNTIME && !MONOMAC
#if !MONOTOUCH && !FULL_AOT_RUNTIME
[Test]
public void CreateInstanceCustomDomain ()
{

View File

@@ -1 +1 @@
61e6a764534426216122856dba783860e8915efe
7cd8184c6e906e7804425471eda17f75ade7c29f

View File

@@ -87,11 +87,9 @@ namespace MonoTests.System
Assert.IsNotNull (bif.Data, "#1");
Assert.IsNull (bif.FileName, "#2");
Assert.IsNull (bif.InnerException, "#3");
Assert.IsNotNull (bif.Message, "#4"); // Could not load file or assembly '' ...
Assert.IsTrue (bif.Message.IndexOf ("''") != -1, "#5");
Assert.IsNotNull (bif.Message, "#4");
Assert.IsNull (bif.FusionLog, "#5");
Assert.IsTrue (bif.ToString ().StartsWith (bif.GetType ().FullName), "#6");
Assert.IsTrue (bif.ToString ().IndexOf ("''") != -1, "#7");
}
[Test]
@@ -139,8 +137,7 @@ namespace MonoTests.System
Assert.IsNull (bif.FileName, "#2");
Assert.IsNotNull (bif.InnerException, "#3");
Assert.AreSame (ame, bif.InnerException, "#4");
Assert.IsNotNull (bif.Message, "#5"); // Could not load file or assembly '' ...
Assert.IsTrue (bif.Message.IndexOf ("''") != -1, "#6");
Assert.IsNotNull (bif.Message, "#5");
Assert.IsNull (bif.FusionLog, "#7");
Assert.IsTrue (bif.ToString ().StartsWith (bif.GetType ().FullName), "#8");
Assert.IsTrue (bif.ToString ().IndexOf ("---> " + ame.GetType ().FullName) != -1, "#9");
@@ -251,8 +248,7 @@ namespace MonoTests.System
Assert.IsNotNull (bif.Data, "#1");
Assert.IsNull (bif.FileName, "#2");
Assert.IsNull (bif.InnerException, "#3");
Assert.IsNotNull (bif.Message, "#4"); // Could not load file or assembly '' ...
Assert.IsTrue (bif.Message.IndexOf ("''") != -1, "#5");
Assert.IsNotNull (bif.Message, "#4");
Assert.IsNull (bif.FusionLog, "#5");
Assert.IsTrue (bif.ToString ().StartsWith (bif.GetType ().FullName
+ ": "), "#6");
@@ -305,6 +301,7 @@ namespace MonoTests.System
Assert.IsNull (bif.InnerException, "#B4");
// .NET 1.1: The format of the file 'file.txt' is invalid
// .NET 2.0: Could not load file or assembly 'file.txt' or one of its ...
// .NET Core: Format of the executable (.exe) or library (.dll) is invalid.
Assert.IsNotNull (bif.Message, "#B5");
Assert.IsNull (bif.FusionLog, "#B6");
Assert.IsTrue (bif.ToString ().StartsWith (bif.GetType ().FullName

View File

@@ -232,7 +232,7 @@ namespace MonoTests.System
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
[Category("MobileNotWorking")]
[Category("NotWorking")]
public void AddHoursOutOfRangeException1 ()
{
DateTime t1 = new DateTime (myTicks [1]);
@@ -241,7 +241,7 @@ namespace MonoTests.System
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
[Category("MobileNotWorking")]
[Category("NotWorking")]
public void AddHoursOutOfRangeException2 ()
{
DateTime t1 = new DateTime (myTicks [1]);
@@ -1611,6 +1611,7 @@ namespace MonoTests.System
}
[Test]
[Category ("NotOnMac")]
public void CultureIndependentTests ()
{
// Here I aggregated some tests mainly because of test

View File

@@ -912,6 +912,7 @@ namespace MonoTests.System
}
[Test]
[Category ("NotWasm")]
public void NullFirstArgumentOnStaticMethod ()
{
CallTarget call = (CallTarget) Delegate.CreateDelegate (

View File

@@ -239,5 +239,11 @@ namespace MonoTests.System
Assert.AreEqual (-1, Environment.MachineName.IndexOf("."));
}
#endif
[Test] // https://github.com/mono/mono/issues/13030
public void GetLogicalDrivesNotEmpty ()
{
CollectionAssert.IsNotEmpty (Environment.GetLogicalDrives ());
}
}
}

View File

@@ -266,6 +266,7 @@ namespace MonoTests.System
}
[Test]
[Category("StackWalks")]
public void GetObjectData ()
{
string msg = "MESSAGE";
@@ -383,6 +384,7 @@ namespace MonoTests.System
}
[Test]
[Category("StackWalks")]
public void Source ()
{
Exception ex1 = new Exception ("MSG");
@@ -405,21 +407,21 @@ namespace MonoTests.System
}
#if !MOBILE
void NestedStackTraces (int depth)
void NestedStackTraces (int depth)
{
if (depth == 0)
throw new ArgumentException ("Depth 0 exception");
if (depth == 0)
throw new ArgumentException ("Depth 0 exception");
try {
NestedStackTraces (depth - 1);
} catch (Exception exc) {
throw new Exception (String.Format ("Depth {0} exception, expect nested", depth), exc);
}
}
void StacktraceToStateTest (int depth)
{
try {
NestedStackTraces (depth);
NestedStackTraces (depth - 1);
} catch (Exception exc) {
throw new Exception (String.Format ("Depth {0} exception, expect nested", depth), exc);
}
}
void StacktraceToStateTest (int depth)
{
try {
NestedStackTraces (depth);
} catch (Exception exc) {
var monoType = Type.GetType ("Mono.Runtime", false);
var convert = monoType.GetMethod("ExceptionToState", BindingFlags.NonPublic | BindingFlags.Static);
@@ -430,41 +432,41 @@ namespace MonoTests.System
var portable_hash = output.Item2;
var unportable_hash = output.Item3;
// To see what we're working with
// Console.WriteLine (dump);
// To see what we're working with
// Console.WriteLine (dump);
Assert.IsTrue (portable_hash != 0, "#1");
Assert.IsTrue (unportable_hash != 0, "#2");
Assert.IsTrue (dump.Length > 0, "#3");
}
}
// Ensure that we can convert a stacktrace to a
// telemetry message
//
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateBase ()
{
StacktraceToStateTest (0);
}
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateDeeper ()
{
StacktraceToStateTest (2);
}
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateOverflow ()
{
// We set a limit on 15 nested exceptions. Lets check that we're valid
// when exceeding that limit.
StacktraceToStateTest (20);
}
// Ensure that we can convert a stacktrace to a
// telemetry message
//
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateBase ()
{
StacktraceToStateTest (0);
}
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateDeeper ()
{
StacktraceToStateTest (2);
}
[Test]
[Category("NotOnWindows")]
public void StacktraceToStateOverflow ()
{
// We set a limit on 15 nested exceptions. Lets check that we're valid
// when exceeding that limit.
StacktraceToStateTest (20);
}
void DumpSingle ()
{
var monoType = Type.GetType ("Mono.Runtime", false);

View File

@@ -29,47 +29,13 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using MonoTests.Helpers;
using NUnit.Framework;
namespace MonoTests.System {
[TestFixture]
public class GCTest {
static class FinalizerHelpers {
private static IntPtr aptr;
private static unsafe void NoPinActionHelper (int depth, Action act)
{
// Avoid tail calls
int* values = stackalloc int [20];
aptr = new IntPtr (values);
if (depth <= 0) {
//
// When the action is called, this new thread might have not allocated
// anything yet in the nursery. This means that the address of the first
// object that would be allocated would be at the start of the tlab and
// implicitly the end of the previous tlab (address which can be in use
// when allocating on another thread, at checking if an object fits in
// this other tlab). We allocate a new dummy object to avoid this type
// of false pinning for most common cases.
//
new object ();
act ();
} else {
NoPinActionHelper (depth - 1, act);
}
}
public static void PerformNoPinAction (Action act)
{
Thread thr = new Thread (() => NoPinActionHelper (128, act));
thr.Start ();
thr.Join ();
}
}
class MyFinalizeObject
{
public volatile static int finalized;
@@ -89,6 +55,7 @@ namespace MonoTests.System {
}
[Test]
[Category ("MultiThreaded")]
public void ReRegisterForFinalizeTest ()
{
FinalizerHelpers.PerformNoPinAction (delegate () {

View File

@@ -283,10 +283,10 @@ namespace MonoTests.System
double b = 0.12371341868561381;
Assert.IsTrue (Math.Abs (a - b) <= 0.0000000000000001, a.ToString ("G99")
+ " != " + b.ToString ("G99"));
Assert.IsTrue (double.IsNaN (Math.Sinh (Double.NaN)));
Assert.IsTrue (double.IsNegativeInfinity (Math.Sinh (Double.NegativeInfinity)));
Assert.IsTrue (double.IsPositiveInfinity (Math.Sinh (Double.PositiveInfinity)));
+ " != " + b.ToString ("G99"));
Assert.IsTrue (double.IsNaN (Math.Sinh (Double.NaN)), "SinH of Nan should be a Nan");
Assert.IsTrue (double.IsNegativeInfinity (Math.Sinh (Double.NegativeInfinity)), "SinH of -inf should be -inf");
Assert.IsTrue (double.IsPositiveInfinity (Math.Sinh (Double.PositiveInfinity)), "SinH of +inf should be +inf");
}
[Test]
@@ -507,7 +507,10 @@ namespace MonoTests.System
Assert.IsTrue (double.IsNaN (Math.Pow ( -2, double.NaN)), "#9");
Assert.IsTrue (double.IsNaN (Math.Pow ( -1, double.NaN)), "#10");
Assert.IsTrue (double.IsNaN (Math.Pow ( 0, double.NaN)), "#11");
#if !WASM
/* WASM returns NaN */
Assert.IsFalse (double.IsNaN (Math.Pow ( 1, double.NaN)), "#12");
#endif
Assert.IsTrue (double.IsNaN (Math.Pow ( 2, double.NaN)), "#13");
Assert.IsTrue (double.IsNaN (Math.Pow (double.PositiveInfinity, double.NaN)), "#14");
@@ -527,8 +530,11 @@ namespace MonoTests.System
Assert.IsTrue (double.IsNaN (Math.Pow (-1, 2.5)), "#19");
/* x = -1; y = NegativeInfinity or PositiveInfinity -> NaN */
#if !WASM
/* WASM returns NaN */
Assert.IsFalse (double.IsNaN (Math.Pow (-1, double.PositiveInfinity)), "#20");
Assert.IsFalse (double.IsNaN (Math.Pow (-1, double.NegativeInfinity)), "#21");
#endif
/* -1 < x < 1; y = NegativeInfinity -> PositiveInfinity */
Assert.AreEqual (double.PositiveInfinity, Math.Pow (-0.5, double.NegativeInfinity), "#22");
@@ -553,11 +559,15 @@ namespace MonoTests.System
Assert.AreEqual ((double) 0, Math.Pow (0, +2), "#31");
/* x = 1; y is any value except NaN -> 1 */
#if !WASM
Assert.AreEqual ((double) 1, Math.Pow (1, double.NegativeInfinity), "#32");
#endif
Assert.AreEqual ((double) 1, Math.Pow (1, -2), "#33");
Assert.AreEqual ((double) 1, Math.Pow (1, 0), "#34");
Assert.AreEqual ((double) 1, Math.Pow (1, +2), "#35");
#if !WASM
Assert.AreEqual ((double) 1, Math.Pow (1, double.PositiveInfinity), "#36");
#endif
/* x = PositiveInfinity; y < 0 -> 0 */
Assert.AreEqual ((double) 0, Math.Pow (double.PositiveInfinity, -1), "#37");

View File

@@ -1158,13 +1158,13 @@ public class TimeSpanTest {
try {
TimeSpan.ParseExact (null, "g", null);
Assert.Fail ("#A1");
} catch (FormatException) {
} catch (ArgumentNullException) {
}
try {
TimeSpan.ParseExact ("10:12", (string)null, null);
Assert.Fail ("#A2");
} catch (FormatException) {
} catch (ArgumentNullException) {
}
try {

View File

@@ -11,7 +11,7 @@ namespace MonoTests.System
public class CreateAdjustmentRuleException
{
[Test]
[ExpectedException (typeof (ArgumentException))]
[Category ("MobileNotWorking")]
public void DateTimeKindNotUnspecified ()
{
DateTime dateStart = new DateTime (2007,01,01, 0,0,0,DateTimeKind.Utc);

View File

@@ -26,6 +26,7 @@ namespace MonoTests.System
}
[Test] // Bug-44255
[Category ("NotWorking")] // https://github.com/dotnet/coreclr/issues/20837
public void SystemTimeZoneSerializationTests ()
{
foreach (var tmz in TimeZoneInfo.GetSystemTimeZones ())
@@ -54,22 +55,28 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void SerializeCustomZoneWithFloatingDaylightTransitions ()
{
var tz3rules = new TimeZoneInfo.AdjustmentRule[] { TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (new DateTime (1, 1, 1), new DateTime (9999, 12, 31), TimeSpan.FromMinutes (23), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 58, 0), 3, 2, DayOfWeek.Tuesday), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 6, 2, DayOfWeek.Tuesday)) };
var tz3 = TimeZoneInfo.CreateCustomTimeZone ("My Zone 3", TimeSpan.FromHours (-4), "My Zone 3 Name", "My Zone 3 Standard Time", "My Zone 3 Daylight Time", tz3rules);
Assert.AreEqual ("My Zone 3;-240;My Zone 3 Name;My Zone 3 Standard Time;My Zone 3 Daylight Time;[01:01:0001;12:31:9999;23;[0;02:15:58;3;2;2;];[0;02:15:59.999;6;2;2;];];", tz3.ToSerializedString ());
Assert.AreEqual ("My Zone 3;-240;My Zone 3 Name;My Zone 3 Standard Time;My Zone 3 Daylight Time;[01:01:0001;12:31:9999;23;[1;00:00:00;1;1;];[1;00:00:00;12;31;];];", tz3.ToSerializedString ());
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void SerializeCustomZoneWithFixedDaylightTransitions ()
{
var tz4rules = new TimeZoneInfo.AdjustmentRule[] { TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (new DateTime (1, 1, 1), new DateTime (9999, 12, 31), TimeSpan.FromMinutes (23), TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 15, 59, 48), 3, 2), TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 6, 2)) };
var tz4 = TimeZoneInfo.CreateCustomTimeZone ("My Zone 4", TimeSpan.FromHours (-4), "My Zone 4 Name", "My Zone 4 Standard Time", "My Zone 4 Daylight Time", tz4rules);
Assert.AreEqual ("My Zone 4;-240;My Zone 4 Name;My Zone 4 Standard Time;My Zone 4 Daylight Time;[01:01:0001;12:31:9999;23;[1;02:15:59.048;3;2;];[1;02:15:59.999;6;2;];];", tz4.ToSerializedString ());
Assert.AreEqual ("My Zone 4;-240;My Zone 4 Name;My Zone 4 Standard Time;My Zone 4 Daylight Time;[01:01:0001;12:31:9999;23;[1;00:00:00;1;1;];[1;00:00:00;12;31;];];", tz4.ToSerializedString ());
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void SerializeCustomZoneWithMultipleDaylightRules ()
{
var tz5rules = new TimeZoneInfo.AdjustmentRule[] {
@@ -77,10 +84,12 @@ namespace MonoTests.System
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (new DateTime (2013, 1, 1), new DateTime (9999, 12, 31), TimeSpan.FromMinutes (48), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 3, 2, DayOfWeek.Tuesday), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 6, 2, DayOfWeek.Tuesday))
};
var tz5 = TimeZoneInfo.CreateCustomTimeZone ("My Zone 5", TimeSpan.FromHours (-6.75), "My Zone 5 Name", "My Zone 5 Standard Time", "My Zone 5 Daylight Time", tz5rules);
Assert.AreEqual ("My Zone 5;-405;My Zone 5 Name;My Zone 5 Standard Time;My Zone 5 Daylight Time;[01:01:0001;12:31:2012;23;[0;02:15:59.999;3;2;2;];[0;02:15:59.999;6;2;2;];][01:01:2013;12:31:9999;48;[0;02:15:59.999;3;2;2;];[0;02:15:59.999;6;2;2;];];", tz5.ToSerializedString ());
Assert.AreEqual ("My Zone 5;-405;My Zone 5 Name;My Zone 5 Standard Time;My Zone 5 Daylight Time;[01:01:0001;12:31:2012;23;[1;00:00:00;1;1;];[1;00:00:00;12;31;];][01:01:2013;12:31:9999;48;[1;00:00:00;1;1;];[1;00:00:00;12;31;];];", tz5.ToSerializedString ());
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void DeserializeCustomZoneWithOddNamingAndMultipleDaylightRules ()
{
var rule1 = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (new DateTime (1, 1, 1), new DateTime (2012, 12, 31), TimeSpan.FromMinutes (23), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 3, 2, DayOfWeek.Tuesday), TimeZoneInfo.TransitionTime.CreateFloatingDateRule (new DateTime (1, 1, 1, 2, 15, 59, 999), 6, 2, DayOfWeek.Tuesday));
@@ -97,8 +106,8 @@ namespace MonoTests.System
var deserializedRules = tz1.GetAdjustmentRules ();
Assert.AreEqual (2, deserializedRules.Length);
Assert.IsFalse (deserializedRules [0].Equals (deserializedRules [1]));
Assert.IsTrue (rule1.Equals (deserializedRules [0]));
Assert.IsTrue (rule2.Equals (deserializedRules [1]));
Assert.IsFalse (rule1.Equals (deserializedRules [0]));
Assert.IsFalse (rule2.Equals (deserializedRules [1]));
}
[Test]

View File

@@ -28,6 +28,7 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
@@ -81,16 +82,16 @@ namespace MonoTests.System
public static void SetLocal (TimeZoneInfo val)
{
if (localField == null) {
if (Type.GetType ("Mono.Runtime") != null) {
#if MOBILE
localField = typeof (TimeZoneInfo).GetField ("local",
BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic);
} else {
#else
cachedDataField = typeof (TimeZoneInfo).GetField ("s_cachedData",
BindingFlags.Static | BindingFlags.GetField | BindingFlags.NonPublic);
localField = cachedDataField.FieldType.GetField ("m_localTimeZone",
localField = cachedDataField.FieldType.GetField ("_localTimeZone",
BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic);
}
#endif
}
if (cachedDataField != null)
@@ -272,6 +273,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class IsDaylightSavingTimeTests
{
TimeZoneInfo london;
@@ -302,6 +304,7 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
public void DSTTransitions ()
{
DateTime beforeDST = new DateTime (2007, 03, 25, 0, 59, 59, DateTimeKind.Unspecified);
@@ -310,7 +313,7 @@ namespace MonoTests.System
DateTime afterDST = new DateTime (2007, 10, 28, 2, 0, 0, DateTimeKind.Unspecified);
Assert.IsFalse (london.IsDaylightSavingTime (beforeDST), "Just before DST");
Assert.IsTrue (london.IsDaylightSavingTime (startDST), "the first seconds of DST");
Assert.IsTrue (london.IsDaylightSavingTime (endDST), "The last seconds of DST");
Assert.IsFalse (london.IsDaylightSavingTime (endDST), "The last seconds of DST");
Assert.IsFalse (london.IsDaylightSavingTime (afterDST), "Just after DST");
}
@@ -389,7 +392,7 @@ namespace MonoTests.System
{
// In .NET/.Net Core GetUtcOffset() returns the BaseUtcOffset for times within the hour
// lost when DST starts and IsDaylightSavingTime() returns false for datetime and true for datetimeoffset
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
var date = new DateTime (2014, 3, 30 , 2, 0, 0);
@@ -418,48 +421,6 @@ namespace MonoTests.System
Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
}
[Test]
public void TestAthensDST_InDSTDelta_NoTransitions ()
{
if (Environment.OSVersion.Platform != PlatformID.Unix)
Assert.Ignore ("TimeZoneInfo on Mono on Windows and .NET has no transitions");
// Repeat the previous test but this time force using AdjustmentRules by nulling out TimeZoneInfo.transitions
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById ("Europe/Athens");
var transitionsField = typeof (TimeZoneInfo).GetField ("transitions", BindingFlags.Instance | BindingFlags.NonPublic);
var transitions = transitionsField.GetValue (tzi);
Assert.IsNotNull (transitions, "Expected Athens TimeZoneInfo.transitions to be non-null");
transitionsField.SetValue (tzi, null);
try {
var date = new DateTime (2014, 3, 30 , 3, 0, 0);
Assert.IsFalse (tzi.IsDaylightSavingTime (date));
Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
date = new DateTime (2014, 3, 30 , 3, 1, 0);
Assert.IsFalse (tzi.IsDaylightSavingTime (date));
Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
date = new DateTime (2014, 3, 30 , 3, 59, 0);
Assert.IsFalse (tzi.IsDaylightSavingTime (date));
Assert.AreEqual (new TimeSpan (2, 0, 0), tzi.GetUtcOffset (date));
Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
date = new DateTime (2014, 3, 30 , 4, 0, 0);
Assert.IsTrue (tzi.IsDaylightSavingTime (date));
Assert.AreEqual (new TimeSpan (3, 0, 0), tzi.GetUtcOffset (date));
Assert.IsTrue (tzi.IsDaylightSavingTime (new DateTimeOffset (date, tzi.GetUtcOffset (date))));
} finally {
transitionsField.SetValue (tzi, transitions);
}
}
[Test] //Covers #41349
public void TestIsDST_DateTimeOffset ()
{
@@ -500,8 +461,9 @@ namespace MonoTests.System
Assert.AreEqual (new TimeSpan (-5, 0, 0), tzi.GetUtcOffset (date));
}
}
[TestFixture]
[Category ("NotWasm")]
public class ConvertTimeTests_LocalUtc : ConvertTimeTests
{
static TimeZoneInfo oldLocal;
@@ -512,7 +474,7 @@ namespace MonoTests.System
base.CreateTimeZones ();
oldLocal = TimeZoneInfo.Local;
TimeZoneInfoTest.SetLocal (TimeZoneInfo.Utc);
TimeZoneInfoTest.SetLocal (TimeZoneInfo.GetSystemTimeZones().First(t => t.BaseUtcOffset == TimeSpan.Zero));
}
[TearDown]
@@ -523,6 +485,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class ConvertTimeTests
{
TimeZoneInfo london;
@@ -683,6 +646,7 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
public void ConvertTime_DateTime_TimeZoneInfo_DateTimeKindMatch ()
{
var sdt = new DateTime (2014, 1, 9, 23, 0, 0, DateTimeKind.Utc);
@@ -697,7 +661,7 @@ namespace MonoTests.System
sdt = new DateTime (2014, 1, 9, 23, 0, 0);
ddt = TimeZoneInfo.ConvertTime (sdt, TimeZoneInfo.Local);
var expectedKind = (TimeZoneInfo.Local == TimeZoneInfo.Utc)? DateTimeKind.Utc : sdt.Kind;
var expectedKind = (TimeZoneInfo.Local == TimeZoneInfo.Utc)? DateTimeKind.Utc : DateTimeKind.Local;
Assert.AreEqual (expectedKind, ddt.Kind, "#3.1");
Assert.AreEqual (DateTimeKind.Unspecified, sdt.Kind, "#3.2");
}
@@ -782,6 +746,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class IsInvalidTimeTests
{
TimeZoneInfo london;
@@ -816,6 +781,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class IsAmbiguousTimeTests
{
TimeZoneInfo london;
@@ -830,21 +796,23 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
public void AmbiguousDates ()
{
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 1)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 2, 0, 0)));
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 2, 0, 0)));
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 2, 0, 1)));
}
[Test]
[Category ("MobileNotWorking")]
public void AmbiguousUTCDates ()
{
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 0, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 0, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 0, 1, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 0, 59, 59, DateTimeKind.Utc)));
Assert.IsFalse (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0, DateTimeKind.Utc)));
Assert.IsTrue (london.IsAmbiguousTime (new DateTime (2007, 10, 28, 1, 0, 0, DateTimeKind.Utc)));
}
#if SLOW_TESTS
@@ -859,6 +827,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class GetSystemTimeZonesTests
{
[Test]
@@ -911,6 +880,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class FindSystemTimeZoneByIdTests
{
[Test]
@@ -949,10 +919,12 @@ namespace MonoTests.System
}
[Test]
public void NoDSTInKinshasa ()
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void DSTInKinshasa ()
{
TimeZoneInfo kin = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Africa/Kinshasa"));
Assert.IsFalse (kin.SupportsDaylightSavingTime);
Assert.IsTrue (kin.SupportsDaylightSavingTime);
}
[Test]
@@ -1046,6 +1018,7 @@ namespace MonoTests.System
}
[TestFixture]
[Category ("NotWasm")]
public class GetAmbiguousTimeOffsetsTests
{
[Test]
@@ -1214,6 +1187,7 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
public void GetUtcOffset_FromUnspecified ()
{
var d = dst1Start.Add (dstOffset);
@@ -1223,7 +1197,6 @@ namespace MonoTests.System
d = dst1End.Add (-dstOffset);
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0,-1))));
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,1,0, 1))));
d = dst2Start.Add (dstOffset);
@@ -1233,11 +1206,11 @@ namespace MonoTests.System
d = dst2End.Add (-dstOffset);
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0,-1))));
Assert.AreEqual(dstUtcOffset, cairo.GetUtcOffset (d));
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,1,0, 1))));
}
[Test]
[Category ("MobileNotWorking")]
public void GetUtcOffset_FromDateTimeOffset ()
{
DateTimeOffset offset;
@@ -1264,6 +1237,7 @@ namespace MonoTests.System
}
[Test]
[Category ("MobileNotWorking")]
public void DTS_WithMinimalDate ()
{
TimeZoneInfo.TransitionTime startTransition, endTransition;
@@ -1276,44 +1250,65 @@ namespace MonoTests.System
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (DateTime.MinValue, DateTime.MaxValue.Date, TimeSpan.FromHours (-1), startTransition, endTransition) });
var offset = ctz.GetUtcOffset (DateTime.MinValue);
Assert.AreEqual (TimeSpan.FromHours (-5), offset); // TODO: Wrong it should be -6
Assert.AreEqual (TimeSpan.FromHours (-6), offset);
}
}
[TestFixture]
[Category ("NotWasm")]
public class GetDaylightChanges
{
MethodInfo getChanges;
[SetUp]
public void Setup ()
private static void GetDaylightTime (TimeZoneInfo tz, int year, out DateTime start, out DateTime end, out TimeSpan delta)
{
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
getChanges = typeof (TimeZoneInfo).GetMethod ("GetDaylightChanges", flags);
#if !MOBILE
var rule = tz.GetAdjustmentRules ().FirstOrDefault (r => r.DateStart.Year <= year && r.DateEnd.Year >= year);
if (rule == null) {
start = DateTime.MinValue;
end = DateTime.MinValue;
delta = TimeSpan.Zero;
return;
}
var method = typeof (TimeZoneInfo).GetMethod ("GetDaylightTime", BindingFlags.Instance | BindingFlags.NonPublic);
var daylightTime = method.Invoke(tz, new object[] { year, rule, null });
var dts = daylightTime.GetType(); // internal readonly struct DaylightTimeStruct
start = (DateTime) dts.GetField ("Start").GetValue (daylightTime);
end = (DateTime) dts.GetField ("End").GetValue (daylightTime);
delta = (TimeSpan) dts.GetField ("Delta").GetValue (daylightTime);
#else
MethodInfo getChanges = typeof (TimeZoneInfo).GetMethod ("GetDaylightChanges", BindingFlags.Instance | BindingFlags.NonPublic);
var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {year});
start = changes.Start;
end = changes.End;
delta = changes.Delta;
#endif
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void TestSydneyDaylightChanges ()
{
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Australia/Sydney"));
var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
GetDaylightTime (tz, 2014, out DateTime start, out DateTime end, out TimeSpan delta);
Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
Assert.AreEqual (new DateTime (2014, 10, 5, 2, 0, 0), changes.Start);
Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
Assert.AreEqual (new TimeSpan (1, 0, 0), delta);
Assert.AreEqual (new DateTime (2014, 10, 6, 2, 0, 0), start);
Assert.AreEqual (new DateTime (2014, 4, 6, 2, 59, 59), end);
}
[Test]
[Category ("MobileNotWorking")]
[Category ("NotOnWindows")]
public void TestAthensDaylightChanges ()
{
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById (MapTimeZoneId ("Europe/Athens"));
var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
GetDaylightTime (tz, 2014, out DateTime start, out DateTime end, out TimeSpan delta);
Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
Assert.AreEqual (new DateTime (2014, 3, 30, 3, 0, 0), changes.Start);
Assert.AreEqual (new DateTime (2014, 10, 26, 4, 0, 0), changes.End);
Assert.AreEqual (new TimeSpan (0, 0, 0), delta);
Assert.AreEqual (new DateTime (2014, 10, 27, 3, 0, 0), start);
Assert.AreEqual (new DateTime (2014, 03, 30, 2, 59, 59), end);
}
[Test]
@@ -1322,7 +1317,7 @@ namespace MonoTests.System
foreach (var tz in TimeZoneInfo.GetSystemTimeZones ()) {
try {
for (var year = 1950; year <= 2051; year++)
getChanges.Invoke (tz, new object [] {year} );
GetDaylightTime (tz, year, out DateTime start, out DateTime end, out TimeSpan delta);
} catch (Exception e) {
Assert.Fail ("TimeZone " + tz.Id + " exception: " + e.ToString ());
}
@@ -1343,6 +1338,7 @@ namespace MonoTests.System
}
[Test]
[Category ("NotWorking")]
public void Bug31432 ()
{
// Europe/Moscow from failing device

View File

@@ -60,13 +60,9 @@ public class TimeZoneTest {
Assert.IsTrue("EDT" == t1.DaylightName || "Eastern Daylight Time" == t1.DaylightName, "B02");
DaylightTime d1 = t1.GetDaylightChanges (2002);
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "B04");
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");
DaylightTime d2 = t1.GetDaylightChanges (1996);
Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "B06");
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "B07");
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");
DateTime d3 = new DateTime (2002,2,25);
@@ -276,6 +272,7 @@ public class TimeZoneTest {
}
[Test]
[Category ("MobileNotWorking")]
public void GetUTCNowAtDSTBoundaries ()
{
TimeZoneInfo.TransitionTime startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 5, DayOfWeek.Sunday);
@@ -290,9 +287,7 @@ public class TimeZoneTest {
TimeZoneInfo tzInfo = TimeZoneInfo.CreateCustomTimeZone("MY Standard Time", TimeSpan.Zero, "MST", "MST", "MDT", adjustments);
// There is no .NET API to set timezone. Use reflection to assign time zone to the TimeZoneInfo.local field.
FieldInfo localTimeZone = typeof(TimeZoneInfo).GetField("local", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
localTimeZone.SetValue(null, tzInfo);
TimeZoneInfoTest.SetLocal(tzInfo);
DateTime st = new DateTime(2016, 3, 27, 1, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
@@ -303,17 +298,19 @@ public class TimeZoneTest {
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 2));
st = new DateTime(2016, 10, 30, 2, 0, 0, DateTimeKind.Local);
Assert.IsTrue (tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 1));
#if !MOBILE
Assert.IsFalse (tzInfo.IsDaylightSavingTime(st));
Assert.IsFalse (!tzInfo.IsAmbiguousTime(st));
Assert.IsFalse ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 1));
st = new DateTime(2016, 10, 30, 3, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (tzInfo.IsAmbiguousTime(st));
Assert.IsFalse (tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 3));
st = new DateTime(2016, 10, 30, 4, 0, 0, DateTimeKind.Local);
Assert.IsTrue (!tzInfo.IsDaylightSavingTime(st));
Assert.IsTrue (!tzInfo.IsAmbiguousTime(st));
Assert.IsTrue ((TimeZoneInfo.ConvertTimeToUtc(st).Hour == 4));
#endif
}
[Test]
@@ -348,12 +345,11 @@ public class TimeZoneTest {
Assert.Ignore (tz.StandardName + " did not observe daylight saving time during " + year + ".");
var standardOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(-1));
var dstOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(61));
var dstOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(1));
// Assert.AreEqual(standardOffset, tz.GetUtcOffset (dst_end));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add (daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(1)))));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ())));
Assert.AreEqual(dstOffset, tz.GetUtcOffset (dst_end.Add(daylightChanges.Delta.Negate ().Add (TimeSpan.FromSeconds(-1)))));
}
@@ -365,6 +361,7 @@ public class TimeZoneTest {
}
[Test]
[Category ("NotWasm")]
public void FindSystemTimeZoneById ()
{
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById (TimeZoneInfoTest.MapTimeZoneId ("Canada/Eastern"));
@@ -391,6 +388,7 @@ public class TimeZoneTest {
// ref: http://bugzilla.xamarin.com/show_bug.cgi?id=1790
[Test]
[Category ("NotWasm")]
public void GetSystemTimeZones ()
{
Assert.That (TimeZoneInfo.GetSystemTimeZones ().Count, Is.GreaterThan (400), "GetSystemTimeZones");

View File

@@ -1 +1 @@
383ae3ef9dd1b2c400ec51ee81f2076d5153746c
4764f928a33575be51d28de55b54259c83148390

View File

@@ -34,6 +34,8 @@ namespace MonoTests.System
{
#if !MONODROID // Type load segfaults the runtime on ARM64 (https://gist.github.com/grendello/334d06c45376602a9afc)
[TestFixture]
// Currently causes the WASM runtime to abort
[Category("NotWasm")]
public class TypedReferenceTest
{
struct TestFields