Skip to content

Commit 326c472

Browse files
committed
Replace custom Option extension methods with builtin methods
tryFallback -> Option.orElseWith tryFallbackValue -> Option.orElse
1 parent 359ea6b commit 326c472

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Components/TestExplorer.fs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ module Option =
8585
option |> Option.iter f
8686
option
8787

88-
let tryFallback f opt =
89-
match opt with
90-
| Some _ -> opt
91-
| None -> f ()
92-
93-
let tryFallbackValue fallbackOpt opt =
94-
match opt with
95-
| Some _ -> opt
96-
| None -> fallbackOpt
9788

9889
module CancellationToken =
9990
let mergeTokens (tokens: CancellationToken list) =
@@ -322,7 +313,7 @@ module TestResult =
322313
Array.tryFind (fun (line: string) -> line.StartsWith(startsWith)) lines
323314
|> Option.map (fun line -> line.Replace(startsWith, "").TrimStart())
324315

325-
tryFind "Expected:", tryFind "But was:" |> Option.tryFallbackValue (tryFind "Actual:")
316+
tryFind "Expected:", tryFind "But was:" |> Option.orElse (tryFind "Actual:")
326317

327318
expected, actual
328319

@@ -964,7 +955,7 @@ module TestItem =
964955
let codeLocation =
965956
namedNode.Data
966957
|> Option.bind tryDtoToLocation
967-
|> Option.tryFallback (fun _ -> tryGetLocation id)
958+
|> Option.orElseWith (fun _ -> tryGetLocation id)
968959

969960
itemFactory
970961
{ id = id
@@ -2196,7 +2187,7 @@ module Interactions =
21962187

21972188
let tryMatchDisplacedTest (testId: ResultBasedTestId) : TestItem option =
21982189
displacedFragmentMapCache.TryGet(testId)
2199-
|> Option.tryFallback (fun () -> tryMatchTestBySuffix locationCache testId)
2190+
|> Option.orElseWith (fun () -> tryMatchTestBySuffix locationCache testId)
22002191
|> Option.tee (fun matchedId -> displacedFragmentMapCache[testId] <- matchedId)
22012192
|> Option.bind (fun matchedId -> TestItem.tryGetById matchedId testsFromCode)
22022193
|> Option.tee (fun matchedTest ->

0 commit comments

Comments
 (0)