mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-09 05:14:20 +00:00
reenabled clear test, made clear working (#5323)
This commit is contained in:
committed by
Andreas Rumpf
parent
ffd929af41
commit
2c6c865b35
@@ -814,11 +814,14 @@ proc len*[A](t: CountTable[A]): int =
|
||||
## returns the number of keys in `t`.
|
||||
result = t.counter
|
||||
|
||||
proc clear*[A](t: var CountTable[A] | CountTableRef[A]) =
|
||||
proc clear*[A](t: CountTableRef[A]) =
|
||||
## Resets the table so that it is empty.
|
||||
clearImpl()
|
||||
t.counter = 0
|
||||
|
||||
proc clear*[A](t: var CountTable[A]) =
|
||||
## Resets the table so that it is empty.
|
||||
clearImpl()
|
||||
|
||||
iterator pairs*[A](t: CountTable[A]): (A, int) =
|
||||
## iterates over any (key, value) pair in the table `t`.
|
||||
for h in 0..high(t.data):
|
||||
|
||||
@@ -190,28 +190,26 @@ block zeroHashKeysTest:
|
||||
doZeroHashValueTest(toOrderedTable[string,string]({"egg": "sausage"}),
|
||||
"", "spam")
|
||||
|
||||
# Until #4448 is fixed, these tests will fail
|
||||
when false:
|
||||
block clearTableTest:
|
||||
var t = data.toTable
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
block clearTableTest:
|
||||
var t = data.toTable
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
|
||||
block clearOrderedTableTest:
|
||||
var t = data.toOrderedTable
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
block clearOrderedTableTest:
|
||||
var t = data.toOrderedTable
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
|
||||
block clearCountTableTest:
|
||||
var t = initCountTable[string]()
|
||||
t.inc("90", 3)
|
||||
t.inc("12", 2)
|
||||
t.inc("34", 1)
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
block clearCountTableTest:
|
||||
var t = initCountTable[string]()
|
||||
t.inc("90", 3)
|
||||
t.inc("12", 2)
|
||||
t.inc("34", 1)
|
||||
assert t.len() != 0
|
||||
t.clear()
|
||||
assert t.len() == 0
|
||||
|
||||
proc orderedTableSortTest() =
|
||||
var t = initOrderedTable[string, int](2)
|
||||
|
||||
Reference in New Issue
Block a user