Skip to content

Commit 25c00cd

Browse files
committed
fix enumeration + tests
1 parent 4ca6b8b commit 25c00cd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/FSharpPlus/Extensions/Dict.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ module Dict =
187187
member __.Count = System.Int32.MaxValue
188188
member __.ContainsKey (_key: 'TKey) = true
189189
member __.Contains (item: KeyValuePair<'TKey,'TValue>) = obj.ReferenceEquals (item.Value, source)
190-
member __.GetEnumerator () = Seq.empty.GetEnumerator () :> System.Collections.IEnumerator
191-
member __.GetEnumerator () = Seq.empty.GetEnumerator () : IEnumerator<KeyValuePair<'TKey,'TValue>>
190+
member __.GetEnumerator () = invalidOp "Key set is potentially infinite." : System.Collections.IEnumerator
191+
member __.GetEnumerator () = invalidOp "Key set is potentially infinite." : IEnumerator<KeyValuePair<'TKey,'TValue>>
192192
member __.IsReadOnly = true
193193
member __.Values = icollection source
194194
member __.Item

tests/FSharpPlus.Tests/General.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,18 @@ module Functor =
436436
Assert.IsInstanceOf<Option<Async<int>>> (Some testVal10)
437437
areEqual 2 (testVal10 |> Async.RunSynchronously)
438438

439+
let testVal11 = (+) "h" <!> dict [1, "i"; 2, "ello"]
440+
CollectionAssert.AreEqual (dict [(1, "hi"); (2, "hello")], testVal11)
441+
442+
let testVal12 =
443+
let h: IDictionary<int, string> = result "h"
444+
try
445+
(+) <!> h <*> dict [1, "i"; 2, "ello"]
446+
with _ -> dict [0, "failure"]
447+
CollectionAssert.AreEqual (dict [0, "failure"], testVal12)
448+
449+
450+
439451
[<Test>]
440452
let unzip () =
441453
let testVal = unzip {Head = (1, 'a'); Tail = [(2, 'b');(3, 'b')]}

0 commit comments

Comments
 (0)