Imported Upstream version 4.2.0.179

Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent aa7da660d6
commit c042cd0c52
7507 changed files with 90259 additions and 657307 deletions

View File

@ -26,12 +26,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_4_5
using System;
using NUnit.Framework;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using System.Diagnostics;
namespace MonoTests.System.Runtime.ExceptionServices
{
@ -91,10 +90,86 @@ namespace MonoTests.System.Runtime.ExceptionServices
Assert.Fail ("#0");
} catch (OperationCanceledException e) {
Assert.IsFalse (e.StackTrace.Contains ("---"));
Assert.AreEqual (2, e.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Length);
}
}
[Test]
public void LastThrowWins ()
{
Exception e;
try {
throw new Exception ("test");
} catch (Exception e2) {
e = e2;
}
var edi = ExceptionDispatchInfo.Capture (e);
try {
edi.Throw ();
} catch {
}
try {
edi.Throw ();
} catch (Exception ex) {
}
try {
edi.Throw ();
} catch (Exception ex) {
var split = ex.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
Assert.AreEqual (4, split.Length, "#1");
Assert.IsTrue (split [1].Contains ("---"), "#2");
}
}
[Test]
public void ThrowMultipleCaptures ()
{
Exception e;
try {
throw new Exception ("test");
} catch (Exception e2) {
e = e2;
}
var edi = ExceptionDispatchInfo.Capture (e);
try {
edi.Throw ();
} catch (Exception e3) {
edi = ExceptionDispatchInfo.Capture (e3);
}
try {
edi.Throw ();
} catch (Exception ex) {
var split = ex.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
Assert.AreEqual (7, split.Length, "#1");
Assert.IsTrue (split [1].Contains ("---"), "#2");
Assert.IsTrue (split [4].Contains ("---"), "#3");
}
}
[Test]
public void StackTraceUserCopy ()
{
try {
try {
throw new NotImplementedException ();
} catch (Exception e) {
var edi = ExceptionDispatchInfo.Capture (e);
edi.Throw();
}
} catch (Exception ex) {
var st = new StackTrace (ex, true);
var split = ex.StackTrace.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
Assert.AreEqual (4, split.Length, "#1");
Assert.IsTrue (split [1].Contains ("---"), "#2");
}
}
}
}
#endif