-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix #14339: fixes limited VM support for addr * strengthen test * reference bug #16003 * also fixes #13511 * also fixes #14420
- Loading branch information
1 parent
7848da7
commit 3e7077a
Showing
4 changed files
with
160 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,69 @@ | ||
import sequtils, critbits | ||
import std/[sequtils,critbits] | ||
|
||
template main = | ||
var r: CritBitTree[void] | ||
r.incl "abc" | ||
r.incl "xyz" | ||
r.incl "def" | ||
r.incl "definition" | ||
r.incl "prefix" | ||
r.incl "foo" | ||
|
||
var r: CritBitTree[void] | ||
r.incl "abc" | ||
r.incl "xyz" | ||
r.incl "def" | ||
r.incl "definition" | ||
r.incl "prefix" | ||
r.incl "foo" | ||
doAssert r.contains"def" | ||
|
||
doAssert r.contains"def" | ||
r.excl "def" | ||
assert r.missingOrExcl("foo") == false | ||
assert "foo" notin toSeq(r.items) | ||
|
||
r.excl "def" | ||
assert r.missingOrExcl("foo") == false | ||
assert "foo" notin toSeq(r.items) | ||
assert r.missingOrExcl("foo") == true | ||
|
||
assert r.missingOrExcl("foo") == true | ||
assert toSeq(r.items) == @["abc", "definition", "prefix", "xyz"] | ||
|
||
assert toSeq(r.items) == @["abc", "definition", "prefix", "xyz"] | ||
assert toSeq(r.itemsWithPrefix("de")) == @["definition"] | ||
var c = CritBitTree[int]() | ||
|
||
assert toSeq(r.itemsWithPrefix("de")) == @["definition"] | ||
var c = CritBitTree[int]() | ||
c.inc("a") | ||
assert c["a"] == 1 | ||
|
||
c.inc("a") | ||
assert c["a"] == 1 | ||
c.inc("a", 4) | ||
assert c["a"] == 5 | ||
|
||
c.inc("a", 4) | ||
assert c["a"] == 5 | ||
c.inc("a", -5) | ||
assert c["a"] == 0 | ||
|
||
c.inc("a", -5) | ||
assert c["a"] == 0 | ||
c.inc("b", 2) | ||
assert c["b"] == 2 | ||
|
||
c.inc("b", 2) | ||
assert c["b"] == 2 | ||
c.inc("c", 3) | ||
assert c["c"] == 3 | ||
|
||
c.inc("c", 3) | ||
assert c["c"] == 3 | ||
c.inc("a", 1) | ||
assert c["a"] == 1 | ||
|
||
c.inc("a", 1) | ||
assert c["a"] == 1 | ||
var cf = CritBitTree[float]() | ||
|
||
var cf = CritBitTree[float]() | ||
cf.incl("a", 1.0) | ||
assert cf["a"] == 1.0 | ||
|
||
cf.incl("a", 1.0) | ||
assert cf["a"] == 1.0 | ||
cf.incl("b", 2.0) | ||
assert cf["b"] == 2.0 | ||
|
||
cf.incl("b", 2.0) | ||
assert cf["b"] == 2.0 | ||
cf.incl("c", 3.0) | ||
assert cf["c"] == 3.0 | ||
|
||
cf.incl("c", 3.0) | ||
assert cf["c"] == 3.0 | ||
assert cf.len == 3 | ||
cf.excl("c") | ||
assert cf.len == 2 | ||
|
||
assert cf.len == 3 | ||
cf.excl("c") | ||
assert cf.len == 2 | ||
var cb: CritBitTree[string] | ||
cb.incl("help", "help") | ||
for k in cb.keysWithPrefix("helpp"): | ||
doAssert false, "there is no prefix helpp" | ||
|
||
var cb: CritBitTree[string] | ||
cb.incl("help", "help") | ||
for k in cb.keysWithPrefix("helpp"): | ||
doAssert false, "there is no prefix helpp" | ||
block: # bug #14339 | ||
var strings: CritBitTree[int] | ||
discard strings.containsOrIncl("foo", 3) | ||
doAssert strings["foo"] == 3 | ||
|
||
main() | ||
static: main() |