2010-08-03 20:43:57 -05:00
|
|
|
// -*- rust -*-
|
|
|
|
|
|
|
|
use std;
|
|
|
|
import std.map;
|
|
|
|
|
|
|
|
fn test_simple() {
|
2010-08-05 01:09:25 -05:00
|
|
|
log "*** starting test_simple";
|
|
|
|
|
2010-08-03 20:43:57 -05:00
|
|
|
fn eq(&uint x, &uint y) -> bool { ret x == y; }
|
2010-08-24 19:23:09 -05:00
|
|
|
fn hash(&uint u) -> uint {
|
|
|
|
// FIXME: can't use std.util.id since we'd be capturing a type param,
|
|
|
|
// and presently we can't close items over type params.
|
|
|
|
ret u;
|
|
|
|
}
|
2010-08-03 20:43:57 -05:00
|
|
|
|
2010-08-24 19:23:09 -05:00
|
|
|
let map.hashfn[uint] hasher = hash;
|
2010-08-03 20:43:57 -05:00
|
|
|
let map.eqfn[uint] eqer = eq;
|
|
|
|
let map.hashmap[uint, uint] hm = map.mk_hashmap[uint, uint](hasher, eqer);
|
2010-08-24 19:23:09 -05:00
|
|
|
hm.insert(10u, 12u);
|
|
|
|
hm.insert(11u, 13u);
|
|
|
|
hm.insert(12u, 14u);
|
2010-08-24 19:38:04 -05:00
|
|
|
|
|
|
|
check (hm.get(11u) == 13u);
|
|
|
|
check (hm.get(12u) == 14u);
|
2010-08-25 13:08:37 -05:00
|
|
|
check (hm.get(10u) == 12u);
|
2010-08-24 19:38:04 -05:00
|
|
|
|
2010-08-05 01:09:25 -05:00
|
|
|
log "*** finished test_simple";
|
2010-08-03 20:43:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test_simple();
|
2010-08-05 01:09:25 -05:00
|
|
|
}
|