You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/FSharpPlus/Control/Applicative.fs
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,8 @@ type Apply =
29
29
static member ``<*>`` (struct(f:Task<_>,x:Task<'T>),_output:Task<'U>,[<Optional>]_mthd:Apply)= Task.apply f x : Task<'U>
30
30
#endif
31
31
#if!NET45 &&!NETSTANDARD2_0 &&!FABLE_COMPILER
32
-
static member ``<*>`` (struct(f:ValueTask<_>,x:ValueTask<'T>),_output:ValueTask<'U>,[<Optional>]_mthd:Default2)= ValueTask.apply f x : ValueTask<'U>
32
+
static member ``<*>`` (struct(f:ValueTask<_>,x:ValueTask<'T>),_output:ValueTask<'U>,[<Optional>]_mthd:Apply):ValueTask<'U>= ValueTask.apply f x
33
+
static member ``<*>`` (struct(_:DmStruct1<_>,_:DmStruct1<'T>),_output:DmStruct1<'U>,[<Optional>]_mthd:Apply):DmStruct1<'U>= Unchecked.defaultof<DmStruct1<'U>>
33
34
#endif
34
35
static member ``<*>`` (struct(f:Async<_>,x:Async<'T>),_output:Async<'U>,[<Optional>]_mthd:Apply)= Async.apply f x : Async<'U>
35
36
static member ``<*>`` (struct(f:option<_>,x:option<'T>),_output:option<'U>,[<Optional>]_mthd:Apply)= Option.apply f x : option<'U>
Assert.AreEqual (true,(t13 |>Async.AsTaskAndWait).IsFaulted,"Async.zip(3) between a value, an exception and a cancellation -> exception wins.")
66
-
letac2=(t13 |>Async.AsTaskAndWait).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
64
+
Assert.AreEqual (true, Async.AsTaskAndWait(t13).IsFaulted,"Async.zip(3) between a value, an exception and a cancellation -> exception wins.")
65
+
letac2= Async.AsTaskAndWait(t13).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
67
66
CollectionAssert.AreEquivalent ([1;3], ac2,"Async.zip between 2 exceptions => both exceptions returned, even after combining with cancellation and values.")
68
67
69
68
[<Test>]
@@ -85,15 +84,27 @@ module Async =
85
84
lett12123= Async.zip3 t12t12 t33 t4
86
85
letac1=
87
86
try
88
-
(t12123 |>Async.AsTaskAndWait).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
87
+
Async.AsTaskAndWait(t12123).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
89
88
with e ->
90
-
failwithf "Failure in testAsyncZipAsync. Async status is %A . Exception is %A"(t12123 |>Async.AsTaskAndWait).Status e
89
+
failwithf "Failure in testAsyncZipAsync. Async status is %A . Exception is %A"(Async.AsTaskAndWait t12123).Status e
91
90
92
91
CollectionAssert.AreEquivalent ([1;2;1;2;3], ac1,"Async.zip(3)Async should add only non already existing exceptions.")
Assert.AreEqual (true,(t13 |>Async.AsTaskAndWait).IsFaulted,"Async.zip(3)Async between a value, an exception and a cancellation -> exception wins.")
96
-
letac2=(t13 |>Async.AsTaskAndWait).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
94
+
Assert.AreEqual (true, Async.AsTaskAndWait(t13).IsFaulted,"Async.zip(3)Async between a value, an exception and a cancellation -> exception wins.")
95
+
letac2= Async.AsTaskAndWait(t13).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
97
96
CollectionAssert.AreEquivalent ([1;3], ac2,"Async.zipAsync between 2 exceptions => both exceptions returned, even after combining with cancellation and values.")
98
97
98
+
[<Test>]
99
+
lettestAsyncTraversals=
100
+
lett1= createAsync true201
101
+
lett2= createAsync true102
102
+
lett3= createAsync false303
103
+
104
+
lett123= Async.map3 (fun x y z ->[x; y; z]) t1 t2 t3
CollectionAssert.AreEquivalent ((Async.AsTaskAndWait t123).Exception.InnerExceptions,(Async.AsTaskAndWait t123').Exception.InnerExceptions,"Async.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is the same as transpose [t1; t2; t3]")
108
+
CollectionAssert.AreNotEquivalent ((Async.AsTaskAndWait t123).Exception.InnerExceptions,(Async.AsTaskAndWait t123'').Exception.InnerExceptions,"Async.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is not the same as sequence [t1; t2; t3]")
Copy file name to clipboardExpand all lines: tests/FSharpPlus.Tests/Task.fs
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -227,6 +227,18 @@ module Task =
227
227
letac2= t13.Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
228
228
CollectionAssert.AreEquivalent ([1;3], ac2,"Task.zipAsync between 2 exceptions => both exceptions returned, even after combining with cancellation and values.")
229
229
230
+
[<Test>]
231
+
lettestTaskTraversals=
232
+
lett1= createTask true201
233
+
lett2= createTask true102
234
+
lett3= createTask false303
235
+
236
+
lett123= Task.map3 (fun x y z ->[x; y; z]) t1 t2 t3
237
+
lett123' = transpose [t1; t2; t3]
238
+
lett123'' = sequence [t1; t2; t3]
239
+
CollectionAssert.AreEquivalent (t123.Exception.InnerExceptions, t123'.Exception.InnerExceptions,"Task.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is the same as transpose [t1; t2; t3]")
240
+
CollectionAssert.AreNotEquivalent (t123.Exception.InnerExceptions, t123''.Exception.InnerExceptions,"Task.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is not the same as sequence [t1; t2; t3]")
Assert.AreEqual (true, t13.IsFaulted,"ValueTask.zip(3)Async between a value, an exception and a cancellation -> exception wins.")
186
185
letac2=(t13.AsTask ()).Exception.InnerExceptions |> Seq.map (fun x -> int (Char.GetNumericValue x.Message.[35]))
187
186
CollectionAssert.AreEquivalent ([1;3], ac2,"ValueTask.zipAsync between 2 exceptions => both exceptions returned, even after combining with cancellation and values.")
188
-
187
+
188
+
[<Test>]
189
+
lettestTaskTraversals=
190
+
lett1= createValueTask true201
191
+
lett2= createValueTask true102
192
+
lett3= createValueTask false303
193
+
194
+
lett123= ValueTask.map3 (fun x y z ->[x; y; z]) t1 t2 t3
195
+
lett123' = transpose [t1; t2; t3]
196
+
lett123'' = sequence [t1; t2; t3]
197
+
CollectionAssert.AreEquivalent (t123.AsTask().Exception.InnerExceptions, t123'.AsTask().Exception.InnerExceptions,"ValueTask.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is the same as transpose [t1; t2; t3]")
198
+
CollectionAssert.AreNotEquivalent (t123.AsTask().Exception.InnerExceptions, t123''.AsTask().Exception.InnerExceptions,"ValueTask.map3 (fun x y z -> [x; y; z]) t1 t2 t3 is not the same as sequence [t1; t2; t3]")
0 commit comments