Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rzikm committed Jan 5, 2024
1 parent 0063373 commit 54ffdcc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docsrc/content/extensions.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ The String type:
* truncate, drop
* findIndex, tryFindIndex
* findSliceIndex, tryFindSliceIndex
* findLastSliceIndex, tryFindLastSliceIndex
* toArray, ofArray, toList, ofList, toSeq, ofSeq, toCodePoints, ofCodePoints
* getBytes
Expand All @@ -195,6 +196,7 @@ Collections / Traversable types:
* intercalate, intersperse,
* split, replace,
* findSliceIndex, trySliceIndex,
* findLastSliceIndex, tryLastSliceIndex,
* partitionMap
* [IList](reference/fsharpplus-ilist.html)
* toIReadOnlyList
Expand All @@ -207,6 +209,7 @@ Collections / Traversable types:
* split, replace,
* toIReadOnlyList,
* findSliceIndex, tryFindSliceIndex,
* findLastSliceIndex, tryLastSliceIndex,
* partitionMap
* setAt, removeAt
* [Enumerator](reference/fsharpplus-enumerator.html)
Expand All @@ -232,6 +235,7 @@ Collections / Traversable types:
* replicate
* toIReadOnlyList
* findSliceIndex, tryFindSliceIndex
* findLastSliceIndex, tryLastSliceIndex,
* [ IReadOnlyCollection ](reference/fsharpplus-ireadonlycollection.html)
* ofArray, ofList, ofSeq
* map
Expand Down
4 changes: 2 additions & 2 deletions src/FSharpPlus/Internals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ module FindLastSliceIndex =
// we assume the slice is finite (otherwise it cannot be searched)
let slice = slice |> Seq.toArray
use sourceEnumerator = source.GetEnumerator()
// we also assume either the source is finite
// we also assume the source is finite
let rec go last index =
if sourceEnumerator.MoveNext() then
cache.Enqueue sourceEnumerator.Current
Expand Down Expand Up @@ -503,7 +503,7 @@ module FindLastSliceIndex =
let h = source.[index]
cache.Enqueue h
if cache.Count = slice.Length then
if sequenceEqual cache revSlice then index - slice.Length + 1
if sequenceEqual cache revSlice then index
else
cache.Dequeue() |> ignore
go (index - 1)
Expand Down
3 changes: 0 additions & 3 deletions tests/FSharpPlus.Tests/General.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ type WrappedListD<'s> = WrappedListD of 's list with
WrappedListD <!> (traversei f x : ^r)
static member FindIndex (WrappedListD x, y) =
SideEffects.add "Using WrappedListD's FindIndex"
printfn "WrappedListD.FindIndex"
findIndex y x
static member FindSliceIndex (WrappedListD x, WrappedListD y) =
SideEffects.add "Using WrappedListD's FindSliceIndex"
printfn "WrappedListD.FindSliceIndex"
findSliceIndex y x
static member FindLastSliceIndex (WrappedListD x, WrappedListD y) =
SideEffects.add "Using WrappedListD's FindLastSliceIndex"
printfn "WrappedListD.FindLastSliceIndex"
findLastSliceIndex y x
member this.Length =
SideEffects.add "Using WrappedListD's Length"
Expand Down
5 changes: 3 additions & 2 deletions tests/FSharpPlusFable.Tests/FSharpTests/General/Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ type WrappedListD<'s> = WrappedListD of 's list with
WrappedListD <!> (traversei f x : ^r)
static member FindIndex (WrappedListD x, y) =
SideEffects.add "Using WrappedListD's FindIndex"
printfn "WrappedListD.FindIndex"
findIndex y x
static member FindSliceIndex (WrappedListD x, WrappedListD y) =
SideEffects.add "Using WrappedListD's FindSliceIndex"
printfn "WrappedListD.FindSliceIndex"
findSliceIndex y x
static member FindLastSliceIndex (WrappedListD x, WrappedListD y) =
SideEffects.add "Using WrappedListD's FindLastSliceIndex"
findLastSliceIndex y x
member this.Length =
SideEffects.add "Using WrappedListD's Length"
let (WrappedListD lst) = this
Expand Down

0 comments on commit 54ffdcc

Please sign in to comment.