aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-08-26 14:44:03 -0700
committerRoy Frostig <[email protected]>2010-08-26 14:44:11 -0700
commit8559a85ccacf70c51d93759b47a3880ae818b247 (patch)
treea876043c326e22a467f644c4bdd3994aaa8fb083 /src/test
parentAdd check to catch bug underlying issue #152. Fix will take longer. (diff)
downloadrust-8559a85ccacf70c51d93759b47a3880ae818b247.tar.xz
rust-8559a85ccacf70c51d93759b47a3880ae818b247.zip
When copying function values, null out the destination's binding iff the source's binding is null.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/lib-map.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/test/run-pass/lib-map.rs b/src/test/run-pass/lib-map.rs
index bc70e51c..51285c06 100644
--- a/src/test/run-pass/lib-map.rs
+++ b/src/test/run-pass/lib-map.rs
@@ -13,11 +13,8 @@ fn test_simple() {
ret u;
}
- // FIXME we don't really want to bind here but if we don't then the
- // hashmap's drop glue UMRs when trying to drop these functions, which
- // it stores internally.
- let map.hashfn[uint] hasher = bind hash(_);
- let map.eqfn[uint] eqer = bind eq(_, _);
+ let map.hashfn[uint] hasher = hash;
+ let map.eqfn[uint] eqer = eq;
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
hm.insert(10u, 12u);
@@ -43,7 +40,7 @@ fn test_simple() {
fn test_growth() {
log "*** starting test_growth";
- let uint map_capacity = 64u; // Keep in sync with map.mk_hashmap
+ let uint num_to_insert = 64u;
fn eq(&uint x, &uint y) -> bool { ret x == y; }
fn hash(&uint u) -> uint {
@@ -52,13 +49,12 @@ fn test_growth() {
ret u;
}
- // FIXME: as in test_simple(), don't really want to bind.
- let map.hashfn[uint] hasher = bind hash(_);
- let map.eqfn[uint] eqer = bind eq(_, _);
+ let map.hashfn[uint] hasher = hash;
+ let map.eqfn[uint] eqer = eq;
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
let uint i = 0u;
- while (i < map_capacity) {
+ while (i < num_to_insert) {
hm.insert(i, i * i);
log "inserting " + std._uint.to_str(i, 10u)
+ " -> " + std._uint.to_str(i * i, 10u);
@@ -68,22 +64,22 @@ fn test_growth() {
log "-----";
i = 0u;
- while (i < map_capacity) {
+ while (i < num_to_insert) {
log "get(" + std._uint.to_str(i, 10u) + ") = "
+ std._uint.to_str(hm.get(i), 10u);
check (hm.get(i) == i * i);
i += 1u;
}
- hm.insert(map_capacity, 17u);
- check (hm.get(map_capacity) == 17u);
+ hm.insert(num_to_insert, 17u);
+ check (hm.get(num_to_insert) == 17u);
log "-----";
hm.rehash();
i = 0u;
- while (i < map_capacity) {
+ while (i < num_to_insert) {
log "get(" + std._uint.to_str(i, 10u) + ") = "
+ std._uint.to_str(hm.get(i), 10u);
check (hm.get(i) == i * i);