Skip to content

Commit 641c284

Browse files
authored
Merge pull request #228 from fsprojects/remove-dead-code
Cleanup: remove dead code, improve test coverage
2 parents 35d5bb7 + da701b6 commit 641c284

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

src/FSharp.Control.TaskSeq.Test/TaskSeq.Append.Tests.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ module SideEffects =
9393
|> validateSequence
9494
|> Task.map (fun () -> i |> should equal 2)
9595

96-
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
97-
let ``TaskSeq-appendSeq consumes whole sequence once incl after-effects`` variant =
96+
[<Fact>]
97+
let ``TaskSeq-appendSeq consumes whole sequence once incl after-effects`` () =
9898
let mutable i = 0
9999

100100
let ts = taskSeq {
@@ -108,8 +108,8 @@ module SideEffects =
108108
|> validateSequence
109109
|> Task.map (fun () -> i |> should equal 2)
110110

111-
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
112-
let ``TaskSeq-prependSeq consumes whole sequence once incl after-effects`` variant =
111+
[<Fact>]
112+
let ``TaskSeq-prependSeq consumes whole sequence once incl after-effects`` () =
113113
let mutable i = 0
114114

115115
taskSeq {

src/FSharp.Control.TaskSeq.Test/TaskSeq.Except.Tests.fs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ module EmptySeq =
5454
let ``TaskSeq-except no side effect in exclude seq if source seq is empty`` variant =
5555
let mutable i = 0
5656

57+
// The `exclude` argument of TaskSeq.except is only iterated after the first item
58+
// from the input. With empty input, this is not evaluated
5759
let exclude = taskSeq {
58-
i <- i + 1
60+
i <- i + 1 // we test that we never get here
5961
yield 12
6062
}
6163

62-
TaskSeq.empty
64+
Gen.getEmptyVariant variant
6365
|> TaskSeq.except exclude
6466
|> verifyEmpty
6567
|> Task.map (fun () -> i |> should equal 0) // exclude seq is only enumerated after first item in source
@@ -96,8 +98,8 @@ module Immutable =
9698
|> TaskSeq.except (Gen.getSeqImmutable variant)
9799
|> verifyEmpty
98100

99-
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
100-
let ``TaskSeq-exceptOfSeq removes duplicates`` variant =
101+
[<Fact>]
102+
let ``TaskSeq-exceptOfSeq removes duplicates`` () =
101103
TaskSeq.ofList [ 1; 1; 2; 3; 4; 12; 12; 12; 13; 13; 13; 13; 13; 99 ]
102104
|> TaskSeq.exceptOfSeq [ 1..10 ]
103105
|> TaskSeq.toArrayAsync

src/FSharp.Control.TaskSeq.Test/TaskSeq.Pick.Tests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ module Immutable =
126126
twentyFive |> should equal "foo"
127127
}
128128

129-
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
130-
let ``TaskSeq-pick happy path first item of seq`` variant = task {
129+
[<Fact>]
130+
let ``TaskSeq-pick happy path first item of seq`` () = task {
131131
let! first =
132132
Gen.sideEffectTaskSeqMicro 50L<µs> 1000L<µs> 50
133133
|> TaskSeq.pick (fun x -> if x = 1 then Some $"first{x}" else None) // dummy tasks seq starts at 1

src/FSharp.Control.TaskSeq.Test/TaskSeq.Realworld.fs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ type AsyncBufferedReader(_output: ITestOutputHelper, data, blockSize) =
4444
let! bytesRead = buffered.ReadAsync(mem, 0, mem.Length) // offset refers to offset in target buffer, not source
4545
lastPos <- buffered.Position
4646

47-
let x: seq<Guid> = seq { 1 } |> Seq.cast
48-
4947
if bytesRead > 0 then
5048
current <- ValueSome mem
5149
return true
@@ -102,11 +100,14 @@ type ``Real world tests``(output: ITestOutputHelper) =
102100

103101
[<Fact(Skip = "Broken test, faulty streaming test-implementation")>]
104102
let ``Reading a 10MB buffered IAsync stream from start to finish`` () = task {
103+
// TODO: fix this test Remove underscores of the vars and rerun the test with
104+
// all lined uncommented
105105
let mutable count = 0
106-
use reader = AsyncBufferedReader(output, Array.init 2048 byte, 256)
106+
use reader = new AsyncBufferedReader(output, Array.init 2048 byte, 256)
107107
let expected = Array.init 256 byte
108108

109-
let ts = taskSeq {
109+
// TODO: use this
110+
let _ts = taskSeq {
110111
for data in reader do
111112
do count <- count + 1
112113

@@ -116,7 +117,7 @@ type ``Real world tests``(output: ITestOutputHelper) =
116117
yield data
117118
}
118119

119-
// the following is extremely slow, which is why we just use F#'s comparison instead
120+
// the following is extremely slow in XUnit/FsUnit, which is why we just use F#'s comparison instead
120121
// Using this takes 67s, compared to 0.25s using normal F# comparison.
121122
// reader |> TaskSeq.toArray |> should equal expected // VERY SLOW!!
122123

src/FSharp.Control.TaskSeq.Test/TaskSeq.ToXXX.Tests.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module SideEffects =
138138

139139
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
140140
let ``TaskSeq-toListAsync should execute side effects multiple times`` variant = task {
141-
let tq = Gen.sideEffectTaskSeq 10
141+
let tq = Gen.getSeqWithSideEffect variant
142142
let! (results1: list<_>) = tq |> TaskSeq.toListAsync
143143
let! (results2: list<_>) = tq |> TaskSeq.toListAsync
144144
results1 |> should equal [ 1..10 ]

0 commit comments

Comments
 (0)