diff options
| author | Marijn Haverbeke <[email protected]> | 2011-05-06 22:13:13 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <[email protected]> | 2011-05-06 22:51:19 +0200 |
| commit | a3ec0b1f643d00b9418e4884bd7caa07bf052201 (patch) | |
| tree | 82000510ac9c9cf3f0c7cf4ae5f3c6b123b559cb /src/test/run-pass/lib-map.rs | |
| parent | Register new snapshots. (diff) | |
| download | rust-a3ec0b1f643d00b9418e4884bd7caa07bf052201.tar.xz rust-a3ec0b1f643d00b9418e4884bd7caa07bf052201.zip | |
Rename std modules to be camelcased
(Have fun mergining your stuff with this.)
Diffstat (limited to 'src/test/run-pass/lib-map.rs')
| -rw-r--r-- | src/test/run-pass/lib-map.rs | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/src/test/run-pass/lib-map.rs b/src/test/run-pass/lib-map.rs index abd2041e..1f956055 100644 --- a/src/test/run-pass/lib-map.rs +++ b/src/test/run-pass/lib-map.rs @@ -1,31 +1,31 @@ // -*- rust -*- use std; -import std.map; -import std._str; -import std._uint; -import std.util; +import std.Map; +import std.Str; +import std.UInt; +import std.Util; fn test_simple() { log "*** starting test_simple"; fn eq_uint(&uint x, &uint y) -> bool { ret x == y; } fn hash_uint(&uint u) -> uint { - // FIXME: can't use std.util.id since we'd be capturing a type param, + // 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; } - let map.hashfn[uint] hasher_uint = hash_uint; - let map.eqfn[uint] eqer_uint = eq_uint; + let Map.hashfn[uint] hasher_uint = hash_uint; + let Map.eqfn[uint] eqer_uint = eq_uint; - let map.hashfn[str] hasher_str = _str.hash; - let map.eqfn[str] eqer_str = _str.eq; + let Map.hashfn[str] hasher_str = Str.hash; + let Map.eqfn[str] eqer_str = Str.eq; log "uint -> uint"; - let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint, + let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint, eqer_uint); assert (hm_uu.insert(10u, 12u)); @@ -49,7 +49,7 @@ fn test_simple() { log "str -> uint"; - let map.hashmap[str, uint] hm_su = map.mk_hashmap[str, uint](hasher_str, + let Map.hashmap[str, uint] hm_su = Map.mk_hashmap[str, uint](hasher_str, eqer_str); assert (hm_su.insert("ten", 12u)); assert (hm_su.insert(eleven, 13u)); @@ -70,42 +70,42 @@ fn test_simple() { log "uint -> str"; - let map.hashmap[uint, str] hm_us = map.mk_hashmap[uint, str](hasher_uint, + let Map.hashmap[uint, str] hm_us = Map.mk_hashmap[uint, str](hasher_uint, eqer_uint); assert (hm_us.insert(10u, "twelve")); assert (hm_us.insert(11u, "thirteen")); assert (hm_us.insert(12u, "fourteen")); - assert (_str.eq(hm_us.get(11u), "thirteen")); - assert (_str.eq(hm_us.get(12u), "fourteen")); - assert (_str.eq(hm_us.get(10u), "twelve")); + assert (Str.eq(hm_us.get(11u), "thirteen")); + assert (Str.eq(hm_us.get(12u), "fourteen")); + assert (Str.eq(hm_us.get(10u), "twelve")); assert (!hm_us.insert(12u, "fourteen")); - assert (_str.eq(hm_us.get(12u), "fourteen")); + assert (Str.eq(hm_us.get(12u), "fourteen")); assert (!hm_us.insert(12u, "twelve")); - assert (_str.eq(hm_us.get(12u), "twelve")); + assert (Str.eq(hm_us.get(12u), "twelve")); log "str -> str"; - let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str, + let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str, eqer_str); assert (hm_ss.insert(ten, "twelve")); assert (hm_ss.insert(eleven, "thirteen")); assert (hm_ss.insert(twelve, "fourteen")); - assert (_str.eq(hm_ss.get("eleven"), "thirteen")); - assert (_str.eq(hm_ss.get("twelve"), "fourteen")); - assert (_str.eq(hm_ss.get("ten"), "twelve")); + assert (Str.eq(hm_ss.get("eleven"), "thirteen")); + assert (Str.eq(hm_ss.get("twelve"), "fourteen")); + assert (Str.eq(hm_ss.get("ten"), "twelve")); assert (!hm_ss.insert("twelve", "fourteen")); - assert (_str.eq(hm_ss.get("twelve"), "fourteen")); + assert (Str.eq(hm_ss.get("twelve"), "fourteen")); assert (!hm_ss.insert("twelve", "twelve")); - assert (_str.eq(hm_ss.get("twelve"), "twelve")); + assert (Str.eq(hm_ss.get("twelve"), "twelve")); log "*** finished test_simple"; } @@ -120,7 +120,7 @@ fn test_growth() { fn eq_uint(&uint x, &uint y) -> bool { ret x == y; } fn hash_uint(&uint u) -> uint { - // FIXME: can't use std.util.id since we'd be capturing a type param, + // 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; } @@ -128,16 +128,16 @@ fn test_growth() { log "uint -> uint"; - let map.hashfn[uint] hasher_uint = hash_uint; - let map.eqfn[uint] eqer_uint = eq_uint; - let map.hashmap[uint, uint] hm_uu = map.mk_hashmap[uint, uint](hasher_uint, + let Map.hashfn[uint] hasher_uint = hash_uint; + let Map.eqfn[uint] eqer_uint = eq_uint; + let Map.hashmap[uint, uint] hm_uu = Map.mk_hashmap[uint, uint](hasher_uint, eqer_uint); let uint i = 0u; while (i < num_to_insert) { assert (hm_uu.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 1u; } @@ -145,8 +145,8 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm_uu.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } @@ -160,8 +160,8 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm_uu.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } @@ -169,16 +169,16 @@ fn test_growth() { log "str -> str"; - let map.hashfn[str] hasher_str = _str.hash; - let map.eqfn[str] eqer_str = _str.eq; - let map.hashmap[str, str] hm_ss = map.mk_hashmap[str, str](hasher_str, + let Map.hashfn[str] hasher_str = Str.hash; + let Map.eqfn[str] eqer_str = Str.eq; + let Map.hashmap[str, str] hm_ss = Map.mk_hashmap[str, str](hasher_str, eqer_str); i = 0u; while (i < num_to_insert) { - assert (hm_ss.insert(_uint.to_str(i, 2u), _uint.to_str(i * i, 2u))); - log "inserting \"" + _uint.to_str(i, 2u) - + "\" -> \"" + _uint.to_str(i * i, 2u) + "\""; + assert (hm_ss.insert(UInt.to_str(i, 2u), UInt.to_str(i * i, 2u))); + log "inserting \"" + UInt.to_str(i, 2u) + + "\" -> \"" + UInt.to_str(i * i, 2u) + "\""; i += 1u; } @@ -187,20 +187,20 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { log "get(\"" - + _uint.to_str(i, 2u) + + UInt.to_str(i, 2u) + "\") = \"" - + hm_ss.get(_uint.to_str(i, 2u)) + "\""; + + hm_ss.get(UInt.to_str(i, 2u)) + "\""; - assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)), - _uint.to_str(i * i, 2u))); + assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)), + UInt.to_str(i * i, 2u))); i += 1u; } - assert (hm_ss.insert(_uint.to_str(num_to_insert, 2u), - _uint.to_str(17u, 2u))); + assert (hm_ss.insert(UInt.to_str(num_to_insert, 2u), + UInt.to_str(17u, 2u))); - assert (_str.eq(hm_ss.get(_uint.to_str(num_to_insert, 2u)), - _uint.to_str(17u, 2u))); + assert (Str.eq(hm_ss.get(UInt.to_str(num_to_insert, 2u)), + UInt.to_str(17u, 2u))); log "-----"; @@ -208,10 +208,10 @@ fn test_growth() { i = 0u; while (i < num_to_insert) { - log "get(\"" + _uint.to_str(i, 2u) + "\") = \"" - + hm_ss.get(_uint.to_str(i, 2u)) + "\""; - assert (_str.eq(hm_ss.get(_uint.to_str(i, 2u)), - _uint.to_str(i * i, 2u))); + log "get(\"" + UInt.to_str(i, 2u) + "\") = \"" + + hm_ss.get(UInt.to_str(i, 2u)) + "\""; + assert (Str.eq(hm_ss.get(UInt.to_str(i, 2u)), + UInt.to_str(i * i, 2u))); i += 1u; } @@ -234,15 +234,15 @@ fn test_removal() { assert (hash(2u) == hash(3u)); assert (hash(0u) != hash(2u)); - 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 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 < num_to_insert) { assert (hm.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 1u; } @@ -279,8 +279,8 @@ fn test_removal() { i = 1u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; } @@ -294,8 +294,8 @@ fn test_removal() { i = 1u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; } @@ -305,8 +305,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { assert (hm.insert(i, i * i)); - log "inserting " + _uint.to_str(i, 10u) - + " -> " + _uint.to_str(i * i, 10u); + log "inserting " + UInt.to_str(i, 10u) + + " -> " + UInt.to_str(i * i, 10u); i += 2u; } @@ -316,8 +316,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; } @@ -333,8 +333,8 @@ fn test_removal() { i = 0u; while (i < num_to_insert) { - log "get(" + _uint.to_str(i, 10u) + ") = " - + _uint.to_str(hm.get(i), 10u); + log "get(" + UInt.to_str(i, 10u) + ") = " + + UInt.to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; } |