@@ -41,9 +41,6 @@ let inline IsCancellationExn (e:exn) =
4141let AreCancellationExns ( e1 : exn ) ( e2 : exn ) =
4242 IsCancellationExn e1 && IsCancellationExn e2
4343
44- let runTimeout ( timeoutMs : int ) ( a : Async < 'a >) : 'a =
45- Async.RunSynchronously ( a, timeoutMs)
46-
4744expect.extend( " toEqualAsyncSeq" , fun ( actual : AsyncSeq < obj >) ( expected : AsyncSeq < obj >) ( timeout : int ) ( exnEq : exn -> exn -> bool) ->
4845 async {
4946 let! expected = expected |> AsyncSeq.toListAsync |> AsyncOps.timeoutMs timeout |> Async.Catch
@@ -56,7 +53,7 @@ expect.extend("toEqualAsyncSeq", fun (actual: AsyncSeq<obj>) (expected: AsyncSeq
5653 | _ -> false
5754 |> fun b -> { pass = b; message = fun () -> sprintf " expected = %A actual = %A " expected actual }
5855 } |> Async.StartAsPromise)
59-
56+
6057expect.extend( " toEqualLooseChoice" , fun ( actual : Choice < obj , exn >) ( expected : Choice < obj , exn >) ->
6158 match expected, actual with
6259 | Choice1Of2 exp, Choice1Of2 act -> exp = act
@@ -98,11 +95,11 @@ type Jest with
9895Jest.test( " AsyncSeq.never should equal itself" , async {
9996 let! n1 = AsyncSeq.never< int> |> AsyncSeq.toListAsync |> Async.Catch
10097 let! n2 = AsyncSeq.never< int> |> AsyncSeq.toListAsync |> Async.Catch
101-
98+
10299 Jest.expect( n1) .toEqualLooseChoice( n2)
103100})
104101
105- Jest.describe( " AsyncSeq.concat" , fun () ->
102+ Jest.describe( " AsyncSeq.concat" , fun () ->
106103 Jest.test( " AsyncSeq.concatSeq works" , async {
107104 let ls = [ [ 1 ; 2 ] ; [ 3 ; 4 ] ]
108105 let actual = AsyncSeq.ofSeq ls |> AsyncSeq.concatSeq
@@ -119,7 +116,7 @@ Jest.describe("AsyncSeq.concat", fun () ->
119116 |> AsyncSeq.ofSeq
120117 |> AsyncSeq.concat
121118 |> AsyncSeq.toArrayAsync
122-
119+
123120 let! expected =
124121 Seq.init m ( fun _ -> Seq.init n id)
125122 |> AsyncSeq.ofSeq
@@ -147,7 +144,7 @@ Jest.test("AsyncSeq.length works", async {
147144
148145 Jest.expect( actual64 |> int) .toEqual( expected)
149146})
150-
147+
151148Jest.test( " AsyncSeq.contains works" , async {
152149 for i in 0 .. 10 do
153150 let ls = [ 1 .. i ]
@@ -166,7 +163,7 @@ Jest.describe("AsyncSeq.pick", fun () ->
166163 let chooser x = if x = j then Some ( string ( x+ 1 )) else None
167164 let! actual = AsyncSeq.ofSeq ls |> AsyncSeq.pick chooser |> Async.Catch
168165 let expected = ( fun () -> ls |> Seq.pick chooser) |> catch
169-
166+
170167 do Jest.expect( actual) .toEqualLooseChoice( expected)
171168 })
172169
@@ -176,7 +173,7 @@ Jest.describe("AsyncSeq.pick", fun () ->
176173 for j in [ 0 ; i; i+ 1 ] do
177174 let actual = AsyncSeq.ofSeq ls |> AsyncSeq.tryPick ( fun x -> if x = j then Some ( string ( x+ 1 )) else None)
178175 let expected = ls |> Seq.tryPick ( fun x -> if x = j then Some ( string ( x+ 1 )) else None)
179-
176+
180177 do ! Jest.expect( actual) .toEqual( expected)
181178 })
182179)
@@ -211,7 +208,7 @@ Jest.test("AsyncSeq.forall works", async {
211208 do ! Jest.expect( actual) .toEqual( expected)
212209})
213210
214- Jest.describe( " AsyncSeq.unfold" , fun () ->
211+ Jest.describe( " AsyncSeq.unfold" , fun () ->
215212 Jest.test( " AsyncSeq.unfoldAsync" , async {
216213 let gen s =
217214 if s < 3 then ( s, s + 1 ) |> Some
@@ -221,7 +218,7 @@ Jest.describe("AsyncSeq.unfold", fun () ->
221218
222219 do ! Jest.expect( actual) .toEqualAsyncSeq( expected)
223220 })
224-
221+
225222 Jest.test( " AsyncSeq.unfold" , async {
226223 let gen s =
227224 if s < 3 then ( s, s + 1 ) |> Some
@@ -259,7 +256,7 @@ Jest.describe("AsyncSeq.unfold", fun () ->
259256 })
260257)
261258
262- Jest.describe( " AsyncSeq.interleaveChoice" , fun () ->
259+ Jest.describe( " AsyncSeq.interleaveChoice" , fun () ->
263260 Jest.test( " AsyncSeq.interleaveChoice" , async {
264261 let s1 = AsyncSeq.ofSeq [ " a" ; " b" ; " c" ]
265262 let s2 = AsyncSeq.ofSeq [ 1 ; 2 ; 3 ]
@@ -321,7 +318,7 @@ Jest.describe("AsyncSeq.interleaveChoice", fun () ->
321318 })
322319)
323320
324- Jest.describe( " AsyncSeq.interleave" , fun () ->
321+ Jest.describe( " AsyncSeq.interleave" , fun () ->
325322 Jest.test( " AsyncSeq.interleave" , async {
326323 let s1 = AsyncSeq.ofSeq [ " a" ; " b" ; " c" ]
327324 let s2 = AsyncSeq.ofSeq [ " 1" ; " 2" ; " 3" ]
@@ -402,12 +399,12 @@ Jest.describe("AsyncSeq.interleave", fun () ->
402399
403400 return ! AsyncSeq.interleave s1 s2 |> AsyncSeq.toArrayAsync
404401 }
405-
402+
406403 do ! Jest.expect( f |> Async.StartAsPromise) .rejects.toThrow()
407404 })
408405)
409406
410- Jest.describe( " AsyncSeq.bufferBy" , fun () ->
407+ Jest.describe( " AsyncSeq.bufferBy" , fun () ->
411408 Jest.test( " AsyncSeq.bufferByCount" , async {
412409 let! actual =
413410 asyncSeq {
@@ -433,7 +430,7 @@ Jest.describe("AsyncSeq.bufferBy", fun () ->
433430 }
434431 |> AsyncSeq.bufferByCount 1 |> AsyncSeq.toArrayAsync
435432 let expected = [| for i in 1 .. sz -> [| i|]|]
436-
433+
437434 Jest.expect( actual) .toEqual( expected)
438435 Jest.expect( actual) .toHaveLength( expected.Length)
439436 })
@@ -469,7 +466,7 @@ Jest.describe("AsyncSeq.try", fun () ->
469466
470467 Jest.expect( x.Value) .toBe( 6 )
471468 })
472-
469+
473470 Jest.test( " try finally works exception" , async {
474471 let x = ref 0
475472 let s =
@@ -586,7 +583,7 @@ Jest.describe("AsyncSeq.skip", fun () ->
586583 let p i = i <= 2
587584 let! actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.skipWhileAsync ( p >> async.Return) |> AsyncSeq.toArrayAsync
588585 let! expected = ls |> Seq.skipWhile p |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
589-
586+
590587 Jest.expect( actual) .toEqual( expected)
591588 })
592589
@@ -604,14 +601,14 @@ Jest.describe("AsyncSeq.take", fun () ->
604601 let p i = i < 4
605602 let! actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.takeWhileAsync ( p >> async.Return) |> AsyncSeq.toArrayAsync
606603 let! expected = ls |> Seq.takeWhile p |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
607-
604+
608605 Jest.expect( actual) .toEqual( expected)
609606 })
610607
611608 Jest.test( " AsyncSeq.take should work" , async {
612609 let! sa = asyncSeq { yield [ " a" , 1 ] |> Map.ofList } |> AsyncSeq.take 1 |> AsyncSeq.toArrayAsync
613610 let actual = sa |> ( Array.tryHead >> Option.bind ( Map.tryFind( " a" )))
614-
611+
615612 Jest.expect( actual) .toBeDefined()
616613 Jest.expect( actual.Value) .toBe( 1 )
617614 })
@@ -622,7 +619,7 @@ Jest.describe("AsyncSeq.take", fun () ->
622619 let pInclusive i = i <= 4
623620 let! actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.takeWhileInclusive p |> AsyncSeq.toArrayAsync
624621 let! expected = ls |> Seq.filter( pInclusive) |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
625-
622+
626623 Jest.expect( actual) .toEqual( expected)
627624 })
628625
@@ -650,7 +647,7 @@ Jest.describe("AsyncSeq.scan", fun () ->
650647 let z = 0
651648 let! actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.scanAsync ( fun i a -> f i a |> async.Return) z |> AsyncSeq.toArrayAsync
652649 let! expected = ls |> List.scan f z |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
653-
650+
654651 Jest.expect( actual) .toEqual( expected)
655652 })
656653
@@ -660,12 +657,12 @@ Jest.describe("AsyncSeq.scan", fun () ->
660657 let z = 0
661658 let! actual = ls |> AsyncSeq.ofSeq |> AsyncSeq.scan ( fun i a -> f i a) z |> AsyncSeq.toArrayAsync
662659 let! expected = ls |> List.scan f z |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
663-
660+
664661 Jest.expect( actual) .toEqual( expected)
665662 })
666663)
667664
668- Jest.describe( " AsyncSeq.fold" , fun () ->
665+ Jest.describe( " AsyncSeq.fold" , fun () ->
669666 Jest.test( " AsyncSeq.foldAsync" , async {
670667 for ls in [ []; [ 1 ]; [ 3 ]; [ 1 ; 2 ; 3 ; 4 ; 5 ] ] do
671668 let f i a = i + a
@@ -675,7 +672,7 @@ Jest.describe("AsyncSeq.fold", fun () ->
675672
676673 do ! Jest.expect( actual) .toBe( expected)
677674 })
678-
675+
679676 Jest.test( " AsyncSeq.fold" , async {
680677 for ls in [ []; [ 1 ]; [ 3 ]; [ 1 ; 2 ; 3 ; 4 ; 5 ] ] do
681678 let f i a = i + a
@@ -687,7 +684,7 @@ Jest.describe("AsyncSeq.fold", fun () ->
687684 })
688685)
689686
690- Jest.describe( " AsyncSeq.filter" , fun () ->
687+ Jest.describe( " AsyncSeq.filter" , fun () ->
691688 Jest.test( " AsyncSeq.filterAsync" , async {
692689 for ls in [ []; [ 1 ]; [ 4 ]; [ 1 ; 2 ; 3 ; 4 ; 5 ] ] do
693690 let p i = i > 3
@@ -696,7 +693,7 @@ Jest.describe("AsyncSeq.filter", fun () ->
696693
697694 Jest.expect( actual) .toEqual( expected)
698695 })
699-
696+
700697 Jest.test( " AsyncSeq.filter" , async {
701698 for ls in [ []; [ 1 ]; [ 4 ]; [ 1 ; 2 ; 3 ; 4 ; 5 ] ] do
702699 let p i = i > 3
@@ -707,7 +704,7 @@ Jest.describe("AsyncSeq.filter", fun () ->
707704 })
708705)
709706
710- Jest.describe( " AsyncSeq.replicate" , fun () ->
707+ Jest.describe( " AsyncSeq.replicate" , fun () ->
711708 Jest.test( " AsyncSeq.replicate" , async {
712709 let c = 10
713710 let x = " hello"
@@ -756,15 +753,15 @@ Jest.describe("AsyncSeq.replicate", fun () ->
756753 })
757754)
758755
759- Jest.describe( " AsyncSeq.init" , fun () ->
756+ Jest.describe( " AsyncSeq.init" , fun () ->
760757 Jest.test( " AsyncSeq.init" , async {
761758 for c in [ 0 ; 1 ; 100 ] do
762759 let! actual = AsyncSeq.init ( int64 c) string |> AsyncSeq.toArrayAsync
763760 let! expected = List.init c string |> AsyncSeq.ofSeq |> AsyncSeq.toArrayAsync
764761
765762 Jest.expect( actual) .toEqual( expected)
766763 })
767-
764+
768765 Jest.test( " AsyncSeq.initInfinite" , async {
769766 for c in [ 0 ; 1 ; 100 ] do
770767 let! actual = AsyncSeq.initInfinite string |> AsyncSeq.take c |> AsyncSeq.toArrayAsync
@@ -786,7 +783,7 @@ Jest.describe("AsyncSeq.init", fun () ->
786783
787784 Jest.expect( actual) .toEqual( expected)
788785 })
789-
786+
790787 Jest.test( " AsyncSeq.initInfiniteAsync" , async {
791788 for c in [ 0 ; 1 ; 100 ] do
792789 let! actual = AsyncSeq.initInfiniteAsync ( string >> async.Return) |> AsyncSeq.take c |> AsyncSeq.toArrayAsync
@@ -804,7 +801,7 @@ Jest.test("AsyncSeq.collect works", async {
804801 Jest.expect( actual) .toEqual( expected)
805802})
806803
807- Jest.describe( " AsyncSeq.traverse" , fun () ->
804+ Jest.describe( " AsyncSeq.traverse" , fun () ->
808805 Jest.test( " AsyncSeq.traverseOptionAsync" , async {
809806 let seen = ResizeArray<_>()
810807 let s = [ 1 ; 2 ; 3 ; 4 ; 5 ] |> AsyncSeq.ofSeq
@@ -870,12 +867,12 @@ Jest.test("AsyncSeq.getIterator should work", async {
870867 use i = s1.GetEnumerator()
871868
872869 match ! i.MoveNext() with
873- | None as v -> Jest.expect( v) .toBeDefined()
870+ | None as v -> Jest.expect( v) .toBeDefined()
874871 | Some v ->
875872 Jest.expect( v) .toBe( 1 )
876873
877874 match ! i.MoveNext() with
878- | None as v -> Jest.expect( v) .toBeDefined()
875+ | None as v -> Jest.expect( v) .toBeDefined()
879876 | Some v ->
880877 Jest.expect( v) .toBe( 2 )
881878 do ! Jest.expect( i.MoveNext()) .toBeUndefined()
@@ -934,7 +931,7 @@ Jest.describe("AsyncSeq.intervalMs", fun () ->
934931 actual := ( timestamp |> Array.map ( fun d -> d.Ticks)) |> Array.append actual.Value
935932 }
936933 |> Async.StartImmediate
937-
934+
938935 for i in [ 0 .. 10 ] do
939936 Jest.expect( actual.Value) .toHaveLength( i)
940937
0 commit comments