changeset 105:4d308952fd5e v2

minor fixes
author cin
date Mon, 10 Nov 2014 10:17:54 +0300
parents 5f10d54b45df
children d4e38929ce36
files Implab.Test/AsyncTests.cs Implab/Promise.cs
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Implab.Test/AsyncTests.cs	Sun Nov 09 23:03:45 2014 +0300
+++ b/Implab.Test/AsyncTests.cs	Mon Nov 10 10:17:54 2014 +0300
@@ -139,6 +139,21 @@
         }
 
         [TestMethod]
+        public void ChainFailTest() {
+            var p1 = new Promise<int>();
+
+            var p3 = p1.Chain(x => {
+                var p2 = new Promise<string>();
+                p2.Reject(new Exception("DIE!!!"));
+                return p2;
+            });
+
+            p1.Resolve(100);
+
+            Assert.IsTrue(p3.IsResolved);
+        }
+
+        [TestMethod]
         public void PoolTest() {
             var pid = Thread.CurrentThread.ManagedThreadId;
             var p = AsyncPool.Invoke(() => Thread.CurrentThread.ManagedThreadId);
--- a/Implab/Promise.cs	Sun Nov 09 23:03:45 2014 +0300
+++ b/Implab/Promise.cs	Mon Nov 10 10:17:54 2014 +0300
@@ -893,7 +893,7 @@
 
 
         void IPromise.On(Action success, Action<Exception> error, Action cancel) {
-            On(x => success(), error, cancel);
+            On(success != null ? new Action<T>(x => success()) : null, error, cancel);
         }
 
         void IPromise.On(Action success, Action<Exception> error) {