Skip to content

Commit 32facc6

Browse files
committed
Arduously added logging to each test, there must be a better way to find out whether a test has started (but not finished)
Log "starting a test", because xUnit does not do it
1 parent 3951fbf commit 32facc6

17 files changed

+1878
-1422
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module FSharpy.Tests.Choose
1+
namespace FSharpy.Tests
22

33
open System
44
open System.Threading.Tasks
@@ -8,50 +8,68 @@ open FsUnit.Xunit
88
open FsToolkit.ErrorHandling
99

1010
open FSharpy
11+
open Xunit.Abstractions
1112

12-
[<Fact(Timeout = 10_000)>]
13-
let ``ZHang timeout test`` () = task {
14-
let! empty = Task.Delay 30
15-
16-
empty |> should be Null
17-
}
18-
19-
[<Fact(Timeout = 10_000)>]
20-
let ``TaskSeq-choose on an empty sequence`` () = task {
21-
let! empty =
22-
TaskSeq.empty
23-
|> TaskSeq.choose (fun _ -> Some 42)
24-
|> TaskSeq.toListAsync
25-
26-
List.isEmpty empty |> should be True
27-
}
28-
29-
[<Fact(Timeout = 10_000)>]
30-
let ``TaskSeq-chooseAsync on an empty sequence`` () = task {
31-
let! empty =
32-
TaskSeq.empty
33-
|> TaskSeq.chooseAsync (fun _ -> task { return Some 42 })
34-
|> TaskSeq.toListAsync
35-
36-
List.isEmpty empty |> should be True
37-
}
38-
39-
[<Fact(Timeout = 10_000)>]
40-
let ``TaskSeq-choose can convert and filter`` () = task {
41-
let! alphabet =
42-
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
43-
|> TaskSeq.choose (fun number -> if number <= 26 then Some(char number + '@') else None)
44-
|> TaskSeq.toArrayAsync
45-
46-
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
47-
}
48-
49-
[<Fact(Timeout = 10_000)>]
50-
let ``TaskSeq-chooseAsync can convert and filter`` () = task {
51-
let! alphabet =
52-
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
53-
|> TaskSeq.choose (fun number -> if number <= 26 then Some(char number + '@') else None)
54-
|> TaskSeq.toArrayAsync
55-
56-
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
57-
}
13+
14+
type Choose(output: ITestOutputHelper) =
15+
16+
[<Fact(Timeout = 10_000)>]
17+
let ``ZHang timeout test`` () =
18+
logStart output
19+
20+
task {
21+
let! empty = Task.Delay 30
22+
empty |> should be Null
23+
}
24+
25+
[<Fact(Timeout = 10_000)>]
26+
let ``TaskSeq-choose on an empty sequence`` () =
27+
logStart output
28+
29+
task {
30+
let! empty =
31+
TaskSeq.empty
32+
|> TaskSeq.choose (fun _ -> Some 42)
33+
|> TaskSeq.toListAsync
34+
35+
List.isEmpty empty |> should be True
36+
}
37+
38+
[<Fact(Timeout = 10_000)>]
39+
let ``TaskSeq-chooseAsync on an empty sequence`` () =
40+
logStart output
41+
42+
task {
43+
let! empty =
44+
TaskSeq.empty
45+
|> TaskSeq.chooseAsync (fun _ -> task { return Some 42 })
46+
|> TaskSeq.toListAsync
47+
48+
List.isEmpty empty |> should be True
49+
}
50+
51+
[<Fact(Timeout = 10_000)>]
52+
let ``TaskSeq-choose can convert and filter`` () =
53+
logStart output
54+
55+
task {
56+
let! alphabet =
57+
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
58+
|> TaskSeq.choose (fun number -> if number <= 26 then Some(char number + '@') else None)
59+
|> TaskSeq.toArrayAsync
60+
61+
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
62+
}
63+
64+
[<Fact(Timeout = 10_000)>]
65+
let ``TaskSeq-chooseAsync can convert and filter`` () =
66+
logStart output
67+
68+
task {
69+
let! alphabet =
70+
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
71+
|> TaskSeq.choose (fun number -> if number <= 26 then Some(char number + '@') else None)
72+
|> TaskSeq.toArrayAsync
73+
74+
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
75+
}
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,82 @@
1-
module FSharpy.Tests.Collect
1+
namespace FSharpy.Tests
22

33
open Xunit
44
open FsUnit.Xunit
55
open FsToolkit.ErrorHandling
66

77
open FSharpy
88

9-
[<Fact(Timeout = 10_000)>]
10-
let ``TaskSeq-collect operates in correct order`` () = task {
11-
let! sq =
12-
createDummyTaskSeq 10
13-
|> TaskSeq.collect (fun item -> taskSeq {
14-
yield char (item + 64)
15-
yield char (item + 65)
16-
})
17-
|> TaskSeq.toSeqCachedAsync
18-
19-
sq
20-
|> Seq.map string
21-
|> String.concat ""
22-
|> should equal "ABBCCDDEEFFGGHHIIJJK"
23-
}
24-
25-
[<Fact(Timeout = 10_000)>]
26-
let ``TaskSeq-collectSeq operates in correct order`` () = task {
27-
let! sq =
28-
createDummyTaskSeq 10
29-
|> TaskSeq.collectSeq (fun item -> seq {
30-
yield char (item + 64)
31-
yield char (item + 65)
32-
})
33-
|> TaskSeq.toSeqCachedAsync
34-
35-
sq
36-
|> Seq.map string
37-
|> String.concat ""
38-
|> should equal "ABBCCDDEEFFGGHHIIJJK"
39-
}
40-
41-
[<Fact(Timeout = 10_000)>]
42-
let ``TaskSeq-collect with empty task sequences`` () = task {
43-
let! sq =
44-
createDummyTaskSeq 10
45-
|> TaskSeq.collect (fun _ -> TaskSeq.ofSeq Seq.empty)
46-
|> TaskSeq.toSeqCachedAsync
47-
48-
Seq.isEmpty sq |> should be True
49-
}
50-
51-
[<Fact(Timeout = 10_000)>]
52-
let ``TaskSeq-collectSeq with empty sequences`` () = task {
53-
let! sq =
54-
createDummyTaskSeq 10
55-
|> TaskSeq.collectSeq (fun _ -> Seq.empty<int>)
56-
|> TaskSeq.toSeqCachedAsync
57-
58-
Seq.isEmpty sq |> should be True
59-
}
60-
61-
[<Fact(Timeout = 10_000)>]
62-
let ``TaskSeq-empty is empty`` () = task {
63-
let! sq = TaskSeq.empty<string> |> TaskSeq.toSeqCachedAsync
64-
Seq.isEmpty sq |> should be True
65-
}
9+
type Collect(output) =
10+
11+
[<Fact(Timeout = 10_000)>]
12+
let ``TaskSeq-collect operates in correct order`` () =
13+
logStart output
14+
15+
task {
16+
let! sq =
17+
createDummyTaskSeq 10
18+
|> TaskSeq.collect (fun item -> taskSeq {
19+
yield char (item + 64)
20+
yield char (item + 65)
21+
})
22+
|> TaskSeq.toSeqCachedAsync
23+
24+
sq
25+
|> Seq.map string
26+
|> String.concat ""
27+
|> should equal "ABBCCDDEEFFGGHHIIJJK"
28+
}
29+
30+
[<Fact(Timeout = 10_000)>]
31+
let ``TaskSeq-collectSeq operates in correct order`` () =
32+
logStart output
33+
34+
task {
35+
let! sq =
36+
createDummyTaskSeq 10
37+
|> TaskSeq.collectSeq (fun item -> seq {
38+
yield char (item + 64)
39+
yield char (item + 65)
40+
})
41+
|> TaskSeq.toSeqCachedAsync
42+
43+
sq
44+
|> Seq.map string
45+
|> String.concat ""
46+
|> should equal "ABBCCDDEEFFGGHHIIJJK"
47+
}
48+
49+
[<Fact(Timeout = 10_000)>]
50+
let ``TaskSeq-collect with empty task sequences`` () =
51+
logStart output
52+
53+
task {
54+
let! sq =
55+
createDummyTaskSeq 10
56+
|> TaskSeq.collect (fun _ -> TaskSeq.ofSeq Seq.empty)
57+
|> TaskSeq.toSeqCachedAsync
58+
59+
Seq.isEmpty sq |> should be True
60+
}
61+
62+
[<Fact(Timeout = 10_000)>]
63+
let ``TaskSeq-collectSeq with empty sequences`` () =
64+
logStart output
65+
66+
task {
67+
let! sq =
68+
createDummyTaskSeq 10
69+
|> TaskSeq.collectSeq (fun _ -> Seq.empty<int>)
70+
|> TaskSeq.toSeqCachedAsync
71+
72+
Seq.isEmpty sq |> should be True
73+
}
74+
75+
[<Fact(Timeout = 10_000)>]
76+
let ``TaskSeq-empty is empty`` () =
77+
logStart output
78+
79+
task {
80+
let! sq = TaskSeq.empty<string> |> TaskSeq.toSeqCachedAsync
81+
Seq.isEmpty sq |> should be True
82+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module FSharpy.Tests.Filter
1+
namespace FSharpy.Tests
22

33
open System
44
open Xunit
@@ -7,47 +7,62 @@ open FsToolkit.ErrorHandling
77

88
open FSharpy
99

10-
[<Fact(Timeout = 10_000)>]
11-
let ``TaskSeq-filter on an empty sequence`` () = task {
12-
let! empty =
13-
TaskSeq.empty
14-
|> TaskSeq.filter ((=) 12)
15-
|> TaskSeq.toListAsync
16-
17-
List.isEmpty empty |> should be True
18-
}
19-
20-
[<Fact(Timeout = 10_000)>]
21-
let ``TaskSeq-filterAsync on an empty sequence`` () = task {
22-
let! empty =
23-
TaskSeq.empty
24-
|> TaskSeq.filterAsync (fun x -> task { return x = 12 })
25-
|> TaskSeq.toListAsync
26-
27-
List.isEmpty empty |> should be True
28-
}
29-
30-
[<Fact(Timeout = 10_000)>]
31-
let ``TaskSeq-filter filters correctly`` () = task {
32-
let! alphabet =
33-
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
34-
|> TaskSeq.filter ((<=) 26) // lambda of '>' etc inverts order of args, so this means 'greater than'
35-
|> TaskSeq.map char
36-
|> TaskSeq.map ((+) '@')
37-
|> TaskSeq.toArrayAsync
38-
39-
// we filtered all digits above-or-equal-to 26
40-
String alphabet |> should equal "Z[\]^_`abcdefghijklmnopqr"
41-
}
42-
43-
[<Fact(Timeout = 10_000)>]
44-
let ``TaskSeq-filterAsync filters correctly`` () = task {
45-
let! alphabet =
46-
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
47-
|> TaskSeq.filterAsync (fun x -> task { return x <= 26 })
48-
|> TaskSeq.map char
49-
|> TaskSeq.map ((+) '@')
50-
|> TaskSeq.toArrayAsync
51-
52-
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
53-
}
10+
11+
type Filter(output) =
12+
13+
[<Fact(Timeout = 10_000)>]
14+
let ``TaskSeq-filter on an empty sequence`` () =
15+
logStart output
16+
17+
task {
18+
let! empty =
19+
TaskSeq.empty
20+
|> TaskSeq.filter ((=) 12)
21+
|> TaskSeq.toListAsync
22+
23+
List.isEmpty empty |> should be True
24+
}
25+
26+
[<Fact(Timeout = 10_000)>]
27+
let ``TaskSeq-filterAsync on an empty sequence`` () =
28+
logStart output
29+
30+
task {
31+
let! empty =
32+
TaskSeq.empty
33+
|> TaskSeq.filterAsync (fun x -> task { return x = 12 })
34+
|> TaskSeq.toListAsync
35+
36+
List.isEmpty empty |> should be True
37+
}
38+
39+
[<Fact(Timeout = 10_000)>]
40+
let ``TaskSeq-filter filters correctly`` () =
41+
logStart output
42+
43+
task {
44+
let! alphabet =
45+
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
46+
|> TaskSeq.filter ((<=) 26) // lambda of '>' etc inverts order of args, so this means 'greater than'
47+
|> TaskSeq.map char
48+
|> TaskSeq.map ((+) '@')
49+
|> TaskSeq.toArrayAsync
50+
51+
// we filtered all digits above-or-equal-to 26
52+
String alphabet |> should equal "Z[\]^_`abcdefghijklmnopqr"
53+
}
54+
55+
[<Fact(Timeout = 10_000)>]
56+
let ``TaskSeq-filterAsync filters correctly`` () =
57+
logStart output
58+
59+
task {
60+
let! alphabet =
61+
createDummyTaskSeqWith 50L<µs> 1000L<µs> 50
62+
|> TaskSeq.filterAsync (fun x -> task { return x <= 26 })
63+
|> TaskSeq.map char
64+
|> TaskSeq.map ((+) '@')
65+
|> TaskSeq.toArrayAsync
66+
67+
String alphabet |> should equal "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
68+
}

0 commit comments

Comments
 (0)