Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -0,0 +1,66 @@
//
// AsyncTaskMethodBuilderTest.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2014 Xamarin, Inc (http://www.xamarin.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 System;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
namespace MonoTests.System.Runtime.CompilerServices
{
[TestFixture]
public class AsyncTaskMethodBuilderTest
{
#if !MONOTOUCH
// For some reason MT excludes CallContext handling
[Test]
public void CallContextFlow ()
{
CallContext.LogicalSetData ("name0", "0");
Assert.IsTrue (Task.WhenAll (Work ("A"), Work ("B")).Wait (4000), "#0");
Assert.IsNull (CallContext.LogicalGetData ("A"), "#A");
Assert.IsNull (CallContext.LogicalGetData ("B"), "#B");
}
static async Task Work (string name)
{
Assert.AreEqual ("0", CallContext.LogicalGetData ("name0"), "#1" + name);
CallContext.LogicalSetData ("name", name);
await Task.Delay (10);
var found = CallContext.LogicalGetData ("name");
Assert.AreEqual (name, found, "#2" + name);
}
#endif
}
}

View File

@ -33,6 +33,7 @@ using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
namespace MonoTests.System.Runtime.CompilerServices
{
@ -60,7 +61,7 @@ namespace MonoTests.System.Runtime.CompilerServices
public override void Post (SendOrPostCallback d, object state)
{
if (state is Exception) {
if (state is ExceptionDispatchInfo) {
++PostCounter;
}
}

View File

@ -27,7 +27,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.Runtime.CompilerServices;
@ -79,4 +78,3 @@ namespace MonoTests.System.Runtime.CompilerServices {
}
}
#endif

View File

@ -27,7 +27,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
@ -91,4 +90,3 @@ namespace MonoCasTests.System.Runtime.CompilerServices {
}
}
#endif

View File

@ -27,7 +27,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
@ -87,4 +86,3 @@ namespace MonoTests.System.Runtime.CompilerServices {
}
}
#endif

View File

@ -88,6 +88,37 @@ namespace MonoTests.System.Runtime.CompilerServices
}
}
[Category ("NotWorking")] // Bug #18629
[Test]
public void GetResultAfterMultipleExceptions ()
{
TaskAwaiter<object> awaiter;
CreateFaultedAwaiter (out awaiter);
try {
awaiter.GetResult ();
Assert.Fail ();
} catch (AggregateException ae) {
Assert.IsFalse (ae.StackTrace.Contains ("--- End"), "#1");
Assert.IsTrue (ae.StackTrace.Contains ("CreateFaultedAwaiter"), "#2");
}
}
static void CreateFaultedAwaiter (out TaskAwaiter<object> awaiter)
{
var faultedSource = new TaskCompletionSource<object>();
faultedSource.SetException(new Exception());
awaiter = faultedSource.Task.GetAwaiter ();
try {
awaiter.GetResult ();
} catch {
}
try {
awaiter.GetResult ();
} catch {
}
}
[Test]
public void GetResultCanceled ()
{