Skip to content

Commit 3e37064

Browse files
committed
[Tests] fixed EagerVal and added test
1 parent e8f3c29 commit 3e37064

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

  • src/Test/FSharp.Data.Adaptive.Tests

src/Test/FSharp.Data.Adaptive.Tests/AVal.fs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type EagerVal<'T>(input : aval<'T>) =
132132
let mutable last = None
133133

134134
override x.MarkObject() =
135-
let v = input.GetValue AdaptiveToken.Top
135+
let v = input.GetValue (AdaptiveToken(x))
136136
match last with
137137
| Some old when DefaultEquality.equals old v ->
138138
printfn "shortcut %A" v
@@ -189,6 +189,32 @@ let ``[AVal] eager evaluation`` () =
189189
eager |> AVal.force |> should equal "b"
190190
eager.Level |> should be (greaterThan different.Level)
191191

192+
193+
[<Test>]
194+
let ``[AVal] eager marking`` () =
195+
let a = AVal.init 0
196+
let mod2 = a |> AVal.map (fun v -> v % 2)
197+
let eager = EagerVal(mod2) :> aval<_>
198+
let output = eager |> AVal.map id
199+
200+
output |> AVal.force |> should equal 0
201+
202+
transact (fun () -> a.Value <- 2)
203+
output.OutOfDate |> should be False
204+
output |> AVal.force |> should equal 0
205+
206+
transact (fun () -> a.Value <- 1)
207+
output.OutOfDate |> should be True
208+
output |> AVal.force |> should equal 1
209+
210+
transact (fun () -> a.Value <- 3)
211+
output.OutOfDate |> should be False
212+
output |> AVal.force |> should equal 1
213+
214+
transact (fun () -> a.Value <- 0)
215+
output.OutOfDate |> should be True
216+
output |> AVal.force |> should equal 0
217+
192218
[<Test>]
193219
let ``[AVal] nop change evaluation`` () =
194220

0 commit comments

Comments
 (0)