Skip to content

Commit 34b5e73

Browse files
committed
fix bufferByTime test
1 parent bd6c71b commit 34b5e73

File tree

4 files changed

+33
-48
lines changed

4 files changed

+33
-48
lines changed

src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ open System.Reflection
44
[<assembly: AssemblyTitleAttribute("FSharp.Control.AsyncSeq.Profile7")>]
55
[<assembly: AssemblyProductAttribute("FSharp.Control.AsyncSeq")>]
66
[<assembly: AssemblyDescriptionAttribute("Asynchronous sequences for F#")>]
7-
[<assembly: AssemblyVersionAttribute("2.0.15")>]
8-
[<assembly: AssemblyFileVersionAttribute("2.0.15")>]
7+
[<assembly: AssemblyVersionAttribute("2.0.16")>]
8+
[<assembly: AssemblyFileVersionAttribute("2.0.16")>]
99
do ()
1010

1111
module internal AssemblyVersionInformation =
12-
let [<Literal>] Version = "2.0.15"
13-
let [<Literal>] InformationalVersion = "2.0.15"
12+
let [<Literal>] Version = "2.0.16"
13+
let [<Literal>] InformationalVersion = "2.0.16"

src/FSharp.Control.AsyncSeq/AssemblyInfo.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ open System.Reflection
44
[<assembly: AssemblyTitleAttribute("FSharp.Control.AsyncSeq")>]
55
[<assembly: AssemblyProductAttribute("FSharp.Control.AsyncSeq")>]
66
[<assembly: AssemblyDescriptionAttribute("Asynchronous sequences for F#")>]
7-
[<assembly: AssemblyVersionAttribute("2.0.15")>]
8-
[<assembly: AssemblyFileVersionAttribute("2.0.15")>]
7+
[<assembly: AssemblyVersionAttribute("2.0.16")>]
8+
[<assembly: AssemblyFileVersionAttribute("2.0.16")>]
99
do ()
1010

1111
module internal AssemblyVersionInformation =
12-
let [<Literal>] Version = "2.0.15"
13-
let [<Literal>] InformationalVersion = "2.0.15"
12+
let [<Literal>] Version = "2.0.16"
13+
let [<Literal>] InformationalVersion = "2.0.16"

tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -120,52 +120,37 @@ let collect n =
120120
//run bindUnfold
121121
//run collect
122122

123-
let rec prependToAll (a:'a) (ls:'a list) : 'a list =
124-
match ls with
125-
| [] -> []
126-
| hd::tl -> a::hd::prependToAll a tl
127-
128-
let rec intersperse (a:'a) (ls:'a list) : 'a list =
129-
match ls with
130-
| [] -> []
131-
| hd::tl -> hd::prependToAll a tl
123+
let Y = Choice1Of2
124+
let S = Choice2Of2
125+
126+
let timeMs = 500
132127

133-
let intercalate (l:'a list) (xs:'a list list) : 'a list =
134-
intersperse l xs |> List.concat
128+
let inp0 = [ ]
129+
let exp0 = [ ]
135130

136-
let batch (size:int) (ls:'a list) : 'a list list =
137-
let rec go batch ls =
138-
match ls with
139-
| [] -> [List.rev batch]
140-
| _ when List.length batch = size -> (List.rev batch)::go [] ls
141-
| hd::tl -> go (hd::batch) tl
142-
go [] ls
131+
let inp1 = [ Y 1 ; Y 2 ; S timeMs ; Y 3 ; Y 4 ; S timeMs ; Y 5 ; Y 6 ]
132+
let exp1 = [ [1;2] ; [3;4] ; [5;6] ]
143133

144-
145-
let Y = Choice1Of2
146-
let S = Choice2Of2
147-
let sleepMs = 100
134+
// let inp2 : Choice<int, int> list = [ S 500 ]
135+
// let exp2 : int list list = [ [] ; [] ; [] ; [] ]
148136

149137
let toSeq (xs:Choice<int, int> list) = asyncSeq {
150138
for x in xs do
151139
match x with
152140
| Choice1Of2 v -> yield v
153-
| Choice2Of2 s -> do! Async.Sleep s }
141+
| Choice2Of2 s -> do! Async.Sleep s }
154142

155-
for (size,batchSize) in [ (0,0) ; (10,2) ; (30,2) ] do
143+
for (inp,exp) in [ (inp0,exp0) ; (inp1,exp1) ] do
156144

157-
let expected =
158-
List.init size id
159-
|> batch batchSize
160-
161145
let actual =
162-
expected
163-
|> List.map (List.map Y)
164-
|> intercalate [S sleepMs]
165-
|> toSeq
166-
|> AsyncSeq.bufferByTime sleepMs
146+
toSeq inp
147+
|> AsyncSeq.bufferByTime (timeMs - 5)
167148
|> AsyncSeq.map List.ofArray
168149
|> AsyncSeq.toList
150+
151+
printfn "actual=%A expected=%A" actual exp
152+
153+
//let ls = toSeq inp |> AsyncSeq.toList
154+
//let actualLs = actual |> List.concat
169155

170-
//Assert.True ((actual = expected))
171-
printfn "actual=%A expected=%A" actual expected
156+

tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,12 @@ let ``AsyncSeq.bufferByTime`` () =
452452
let Y = Choice1Of2
453453
let S = Choice2Of2
454454

455-
let timeMs = 100
455+
let timeMs = 500
456456

457457
let inp0 = [ ]
458458
let exp0 = [ ]
459459

460-
let inp1 = [ Y 1 ; Y 2 ; S 100 ; Y 3 ; Y 4 ; S 100 ; Y 5 ; Y 6 ]
460+
let inp1 = [ Y 1 ; Y 2 ; S timeMs ; Y 3 ; Y 4 ; S timeMs ; Y 5 ; Y 6 ]
461461
let exp1 = [ [1;2] ; [3;4] ; [5;6] ]
462462

463463
// let inp2 : Choice<int, int> list = [ S 500 ]
@@ -473,12 +473,12 @@ let ``AsyncSeq.bufferByTime`` () =
473473

474474
let actual =
475475
toSeq inp
476-
|> AsyncSeq.bufferByTime 100
476+
|> AsyncSeq.bufferByTime (timeMs - 5)
477477
|> AsyncSeq.map List.ofArray
478478
|> AsyncSeq.toList
479479

480-
let ls = toSeq inp |> AsyncSeq.toList
481-
let actualLs = actual |> List.concat
480+
//let ls = toSeq inp |> AsyncSeq.toList
481+
//let actualLs = actual |> List.concat
482482

483483
Assert.True ((actual = exp))
484484

0 commit comments

Comments
 (0)