public void PropagatesExceptions()
{
AFnImpl fn = new AFnImpl();
fn._fn0 = () => { throw new Exception("future exception"); };
Future f = new Future(fn);
try
{
f.deref();
Assert.Fail("expected future exception");
}
catch (Exception ex)
{
Expect(ex.Message, EqualTo("Future has an error"));
Expect(ex.InnerException, Is.Not.Null);
Expect(ex.InnerException.Message, EqualTo("future exception"));
}
// Same result for subsequent derefs.
try
{
f.deref();
Assert.Fail("expected future exception");
}
catch (Exception ex)
{
Expect(ex.Message, EqualTo("Future has an error"));
Expect(ex.InnerException, Is.Not.Null);
Expect(ex.InnerException.Message, EqualTo("future exception"));
}
}