Skip to content

Commit 738ffaa

Browse files
xperiandriclaude
andcommitted
fixup! test: contracts of Stack and IStack
`StackOps` and `IStackOps` give the stable sorting contract its new functions `SortIntegersDescending` and `SortIntegersByDescending`. With them, the tests of the contract run for `Stack` and `IStack` too: the descending sorts of 10 000 integers must allocate less than 3 MB, and `sortByDescending` must call the projection in the comparisons, in the order of `List.sortByDescending`. The pipeline of the contract (create the stack, sort it, read it) allocates 1.0 MB with `DescendingSorts` and 7.8 MB with the inline `Seq` sorts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 268f0c9 commit 738ffaa

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎tests/FSharp.Collections.Immutable.Tests/Stack/IStackOps.fs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,7 @@ let stableSort : StableSortOps<IImmutableStack<struct (int * char)>> = {
163163
SortDescending = fun items -> ofSeq items |> IStack.sortDescending |> IStack.toArray
164164
SortWith = IStack.sortWith
165165
SortWithComparer = IStack.sortWithComparer
166+
167+
SortIntegersDescending = fun items -> ofSeq items |> IStack.sortDescending |> IStack.toArray
168+
SortIntegersByDescending = fun items -> ofSeq items |> IStack.sortByDescending id |> IStack.toArray
166169
}

‎tests/FSharp.Collections.Immutable.Tests/Stack/StackOps.fs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,11 @@ let stableSort : StableSortOps<Stack<struct (int * char)>> = {
213213
SortDescending = fun items -> Stack.ofArray items |> Stack.sortDescending |> Stack.toArray
214214
SortWith = Stack.sortWith
215215
SortWithComparer = Stack.sortWithComparer
216+
217+
SortIntegersDescending = fun items -> Stack.ofArray items |> Stack.sortDescending |> Stack.toArray
218+
SortIntegersByDescending =
219+
fun items ->
220+
Stack.ofArray items
221+
|> Stack.sortByDescending id
222+
|> Stack.toArray
216223
}

0 commit comments

Comments
 (0)