Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed trailing whitespaces #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions src/FSharp.Control.Reactive.Testing/Marbles.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// Reactive Marbles representation to make working with recorded test notifications like visualising the notifications as marbles.
module Marbles =

open System
open Microsoft.Reactive.Testing
open FSharp.Control.Reactive.Testing
Expand All @@ -20,8 +20,8 @@ module Marbles =
| Error (t, ex) -> Error (f t, ex)
| Done t -> Done (f t)

let private toNotifications xs =
List.fold (fun (time, ms) x ->
let private toNotifications xs =
List.fold (fun (time, ms) x ->
match x with
| Next (t, v) -> time + t, onNext (time + t) v
| Error (t, ex) -> time + t, onError (time + t) ex
Expand All @@ -31,53 +31,53 @@ module Marbles =
|> List.rev

type private Temperature = Hot | Cold

let private frameMultiplier = 10L
let private frsToTime xs =

let private frsToTime xs =
List.map (fun _ -> frameMultiplier) xs
|> List.fold (+) 0L

let private pframes = many (pchar '-')

let private parseMarbles temp txt =
let txt = txt |> String.filter (fun c -> c <> ' ')

let pvalueOne = noneOf [ '#'; '^'; '|'; '('; ')' ]
let pvalueMultiple =
between
(pchar '(')
(pchar ')')
let pvalueMultiple =
between
(pchar '(')
(pchar ')')
(many1 pvalueOne |>> (Array.ofList >> String))

let pvaluewrap = (pvalueOne |>> string) <|> pvalueMultiple
let pframevalue =
let pframevalue =
pframes .>>. pvaluewrap
|>> fun (frs, x) -> Next (frsToTime frs, x)

let pframeError =
pframes .>> pchar '#'
let pframeError =
pframes .>> pchar '#'
|>> fun frs -> Error (frsToTime frs, exn "error")

let pemit =
let pemit =
attempt pframevalue
<|> attempt pframeError
let pdone =
attempt (pframes .>> pchar '|' |>> (frsToTime >> Some))

let pdone =
attempt (pframes .>> pchar '|' |>> (frsToTime >> Some))
<|> (pframes |>> fun _ -> None)

let pemitsdone =
many pemit .>>. pdone
|>> fun (cs, c) ->
match c with
let pemitsdone =
many pemit .>>. pdone
|>> fun (cs, c) ->
match c with
| Some x -> cs @ [Done x]
| None -> cs

let psub =
pframes .>> pchar '^'
let psub =
pframes .>> pchar '^'
|>> (frsToTime >> (+) frameMultiplier)

let pemitssub =
(many pemit) .>> psub .>>. pemitsdone
|>> fun (xs, ys) ->
Expand All @@ -94,7 +94,7 @@ module Marbles =

let private parseMarblesAsSubscription txt =
let txt = txt |> String.filter (fun c -> c <> ' ')
let psub = pframes .>> pchar '^' |>> frsToTime
let psub = pframes .>> pchar '^' |>> frsToTime
let punsub = pframes .>> pchar '!' |>> (frsToTime >> (+) frameMultiplier)
let psubscriptions = psub .>>. punsub |>> fun (s, u) -> Subscription (s, s + u)

Expand All @@ -104,7 +104,7 @@ module Marbles =

/// Creates from the given marble representation a Cold Observable
/// using the specified `TestScheduler`.
/// Note that the marble representation can't have a subscription marker (`^`),
/// Note that the marble representation can't have a subscription marker (`^`),
/// only Hot Observables can have these.
///
/// ## Parameters
Expand All @@ -125,7 +125,7 @@ module Marbles =
parseMarbles Cold txt

/// Verifies that the given marble representation is indeed the same as the observed messages found in the given test observer.
let expectMessages sch txt obs =
let expectMessages sch txt obs =
TestSchedule.subscribeTestObserverStart sch obs
|> TestObserver.messages =! (parseMarbles Cold txt)

Expand All @@ -136,9 +136,9 @@ module Marbles =
let subscriptions = List.map parseMarblesAsSubscription

/// Verifies that the given marble representation is indeed the same as the subscription found in the given test observable sequence.
let expectSubscription txt xs =
let expectSubscription txt xs =
subscription txt |> (=!) xs

/// Verifies that the given marble representation is indeed the same as the subscriptions found in the given test observable sequence.
let expectSubscriptions txt xs =
let expectSubscriptions txt xs =
subscriptions txt |> (=!) xs
28 changes: 14 additions & 14 deletions src/FSharp.Control.Reactive.Testing/TestNotifications.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ type TestNotifications<'a> = TestNotifications of TestNotification<'a> list

/// The Reactive module provides operators for working with TestObserver<_> in F#.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module TestNotification =
module TestNotification =
open System

let wrap = TestNotifications
let wrap = TestNotifications

/// Unwraps the 'TestNotifications' pattern into a 'TestNotification list'.
let unwrap (TestNotifications xs) = xs
Expand All @@ -37,9 +37,9 @@ module TestNotification =

/// Converts the incoming TestNotification to an Result with:
/// 'OnNext()' notifications as Some and 'OnError()' and 'OnCompleted()' as Error.
let toResult = function
| Next x -> Result.Ok x
| Error ex -> Result.Error ex
let toResult = function
| Next x -> Result.Ok x
| Error ex -> Result.Error ex
| _ -> Result.Error (exn "'OnCompleted'")

/// Filters the incoming TestNotifications on a given predicate function.
Expand All @@ -61,7 +61,7 @@ module TestNotification =
let onCompleted t = ReactiveTest.OnCompleted t

/// Filters the OnNexts recorded notifiation values of the specified list.
let nexts (TestNotifications xs) =
let nexts (TestNotifications xs) =
List.choose (function | Next x -> Some x | _ -> None) xs

/// Maps the OnNext recorded notification values of the specified list to other values.
Expand All @@ -80,30 +80,30 @@ open TestNotification

type GenTestNotification =
static member GenNotifications<'a> () =
let nexts_errors =
Gen.frequency [
let nexts_errors =
Gen.frequency [
(1, Gen.constant (fun t _ -> onError t (new System.Exception ())))
(2, Gen.constant onNext) ]
(2, Gen.constant onNext) ]
|> Gen.listOf

let emits =
Gen.constant (fun h t -> h :: t)
<*> Gen.constant (fun t _ -> onCompleted t)
<*> nexts_errors
|> Gen.map List.rev

let realisticMs = 100L
let growingNumbers l =
let growingNumbers l =
Arb.generate<int64 * 'a>
|> Gen.map (fun (x, y) -> (abs x) + realisticMs, y)
|> Gen.listOfLength l
|> Gen.map (List.sortBy fst)

let zipGrowingNumbers es =
let zipGrowingNumbers es =
growingNumbers (List.length es)
|> Gen.map (List.zip es)
emits

emits
>>= zipGrowingNumbers
|> Gen.map (List.map (fun (f, (x, y)) -> f x y) >> TestNotifications)
|> Arb.fromGen
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Control.Reactive.Testing/TestObserver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ open Microsoft.Reactive.Testing

/// Gets recorded timestamped notification messages received by the observer.
[<Obsolete("Use 'messages' to get all the recored timestamped notifications")>]
let all (o : ITestableObserver<'a>) =
let all (o : ITestableObserver<'a>) =
o.Messages |> Seq.toList |> TestNotifications

/// Gets recorded timestamped notification messages received by the observer.
let messages (o : ITestableObserver<'a>) =
o.Messages |> Seq.toList |> TestNotifications

/// Gets recorded timestamped "OnNext" notification messages received by the observer.
let nexts (o : ITestableObserver<'a>) =
let nexts (o : ITestableObserver<'a>) =
o.Messages |> Seq.toList |> TestNotifications |> TestNotification.nexts

/// Gets recorded timestamped "OnError" notification messages received by the observer.
Expand Down
10 changes: 5 additions & 5 deletions src/FSharp.Control.Reactive.Testing/TestSchedule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ open FSharp.Control.Reactive
open Microsoft.Reactive.Testing

/// Virtual time scheduler used for testing applications and libraries built using Reactive Extensions.
let usage f =
let usage f =
f <| TestScheduler ()

/// Creates a cold observable using the specified timestamped notification messages.
let coldObservable (s : TestScheduler) (TestNotifications ms) =
s.CreateColdObservable<'a> (ms |> List.toArray)

/// Creates a hot observable using the specified timestamped notification messages.
let hotObservable (s : TestScheduler) (TestNotifications ms) =
let hotObservable (s : TestScheduler) (TestNotifications ms) =
s.CreateHotObservable (ms |> List.toArray)

/// Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
let advanceBy (s : TestScheduler) time =
s.AdvanceBy time; s

/// Advances the scheduler's clock to the specified time, running all work till that point.
let advanceTo (s : TestScheduler) time =
s.AdvanceTo time; s
Expand Down
Loading