Remove testutils (#13435) [backport]
This commit is contained in:
parent
8c22518d67
commit
87dd19453b
4 changed files with 11 additions and 20 deletions
|
|
@ -776,11 +776,12 @@ iterator allValues*[A, B](t: Table[A, B]; key: A): B =
|
||||||
## `add proc<#add,Table[A,B],A,B>`_).
|
## `add proc<#add,Table[A,B],A,B>`_).
|
||||||
##
|
##
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
import testutils
|
import sequtils, algorithm
|
||||||
|
|
||||||
var a = {'a': 3, 'b': 5}.toTable
|
var a = {'a': 3, 'b': 5}.toTable
|
||||||
for i in 1..3: a.add('z', 10*i)
|
for i in 1..3: a.add('z', 10*i)
|
||||||
doAssert a.sortedPairs == @[('a', 3), ('b', 5), ('z', 10), ('z', 20), ('z', 30)]
|
doAssert toSeq(a.pairs).sorted == @[('a', 3), ('b', 5), ('z', 10), ('z', 20), ('z', 30)]
|
||||||
doAssert sortedItems(a.allValues('z')) == @[10, 20, 30]
|
doAssert sorted(toSeq(a.allValues('z'))) == @[10, 20, 30]
|
||||||
|
|
||||||
let hc = genHash(key)
|
let hc = genHash(key)
|
||||||
var h: Hash = hc and high(t.data)
|
var h: Hash = hc and high(t.data)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
## Utilities to help writing tests
|
|
||||||
##
|
|
||||||
## Unstable, experimental API.
|
|
||||||
|
|
||||||
import std/[sequtils, algorithm]
|
|
||||||
|
|
||||||
proc sortedPairs*[T](t: T): auto =
|
|
||||||
## helps when writing tests involving tables in a way that's robust to
|
|
||||||
## changes in hashing functions / table implementation.
|
|
||||||
toSeq(t.pairs).sorted
|
|
||||||
|
|
||||||
template sortedItems*(t: untyped): untyped =
|
|
||||||
## helps when writing tests involving tables in a way that's robust to
|
|
||||||
## changes in hashing functions / table implementation.
|
|
||||||
sorted(toSeq(t))
|
|
||||||
|
|
@ -8,7 +8,10 @@ And we get here
|
||||||
'''
|
'''
|
||||||
joinable: false
|
joinable: false
|
||||||
"""
|
"""
|
||||||
import hashes, sequtils, tables, algorithm, testutils
|
import hashes, sequtils, tables, algorithm
|
||||||
|
|
||||||
|
proc sortedPairs[T](t: T): auto = toSeq(t.pairs).sorted
|
||||||
|
template sortedItems(t: untyped): untyped = sorted(toSeq(t))
|
||||||
|
|
||||||
block tableDollar:
|
block tableDollar:
|
||||||
# other tests should use `sortedPairs` to be robust to future table/hash
|
# other tests should use `sortedPairs` to be robust to future table/hash
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ discard """
|
||||||
output: '''true'''
|
output: '''true'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import hashes, tables, sharedtables, testutils
|
import hashes, tables, sharedtables, algorithm, sequtils
|
||||||
|
|
||||||
|
proc sortedPairs[T](t: T): auto = toSeq(t.pairs).sorted
|
||||||
|
|
||||||
const
|
const
|
||||||
data = {
|
data = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue