about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-03-23 21:22:00 -0400
committerAlex Crichton <alex@alexcrichton.com>2013-03-26 19:21:04 -0400
commitb53057f49d7f3994fa394df493f22d9bfdf2df8f (patch)
treee384d0a8fd42a81caa0f7235a8be4346f03ea80e
parent17459d0bd355e550a06ee044de077bcd552e9cc5 (diff)
downloadrust-b53057f49d7f3994fa394df493f22d9bfdf2df8f.tar.gz
rust-b53057f49d7f3994fa394df493f22d9bfdf2df8f.zip
test: Remove uses of oldmap::HashMap
-rw-r--r--src/test/auxiliary/issue-2631-a.rs8
-rw-r--r--src/test/bench/core-std.rs20
-rw-r--r--src/test/bench/graph500-bfs.rs30
-rw-r--r--src/test/bench/shootout-chameneos-redux.rs2
-rw-r--r--src/test/bench/shootout-k-nucleotide-pipes.rs37
-rw-r--r--src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs8
-rw-r--r--src/test/compile-fail/for-loop-decl.rs6
-rw-r--r--src/test/run-pass/extern-mod-syntax.rs2
-rw-r--r--src/test/run-pass/hashmap-memory.rs44
-rw-r--r--src/test/run-pass/issue-1696.rs5
-rw-r--r--src/test/run-pass/issue-2631-b.rs7
-rw-r--r--src/test/run-pass/issue-2804-2.rs8
-rw-r--r--src/test/run-pass/issue-2804.rs14
-rw-r--r--src/test/run-pass/issue-3026.rs6
-rw-r--r--src/test/run-pass/issue-3559.rs3
-rw-r--r--src/test/run-pass/issue-4092.rs4
16 files changed, 88 insertions, 116 deletions
diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs
index f7788c7d57a..fad72ee4eb3 100644
--- a/src/test/auxiliary/issue-2631-a.rs
+++ b/src/test/auxiliary/issue-2631-a.rs
@@ -13,11 +13,11 @@
 
 extern mod std;
 
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
 
-pub type header_map = HashMap<~str, @mut ~[@~str]>;
+pub type header_map = LinearMap<~str, @mut ~[@~str]>;
 
 // the unused ty param is necessary so this gets monomorphized
-pub fn request<T:Copy>(req: header_map) {
-  let _x = copy *(copy *req.get(&~"METHOD"))[0u];
+pub fn request<T:Copy>(req: &header_map) {
+  let _x = copy *(copy **req.get(&~"METHOD"))[0u];
 }
diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs
index eecf509998b..42c79f3af71 100644
--- a/src/test/bench/core-std.rs
+++ b/src/test/bench/core-std.rs
@@ -14,7 +14,6 @@ extern mod std;
 
 use std::time::precise_time_s;
 use std::oldmap;
-use std::oldmap::{Map, HashMap};
 
 use core::io::{Reader, ReaderUtil};
 use core::rand::RngUtil;
@@ -29,7 +28,6 @@ fn main() {
 
     bench!(shift_push);
     bench!(read_line);
-    bench!(str_set);
     bench!(vec_plus);
     bench!(vec_append);
     bench!(vec_push_all);
@@ -73,24 +71,6 @@ fn read_line() {
     }
 }
 
-fn str_set() {
-    let r = rand::Rng();
-
-    let s = oldmap::HashMap();
-
-    for int::range(0, 1000) |_i| {
-        oldmap::set_add(s, r.gen_str(10));
-    }
-
-    let mut found = 0;
-    for int::range(0, 1000) |_i| {
-        match s.find(&r.gen_str(10)) {
-          Some(_) => { found += 1; }
-          None => { }
-        }
-    }
-}
-
 fn vec_plus() {
     let r = rand::Rng();
 
diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs
index b99dfa8bacb..899b86b5cfb 100644
--- a/src/test/bench/graph500-bfs.rs
+++ b/src/test/bench/graph500-bfs.rs
@@ -22,11 +22,9 @@ An implementation of the Graph500 Breadth First Search problem in Rust.
 extern mod std;
 use std::arc;
 use std::time;
-use std::oldmap;
-use std::oldmap::Map;
-use std::oldmap::HashMap;
 use std::deque::Deque;
 use std::par;
+use core::hashmap::linear::{LinearMap, LinearSet};
 use core::io::WriterUtil;
 use core::int::abs;
 use core::rand::RngUtil;
@@ -82,27 +80,31 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] {
 }
 
 fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
-    let graph = do vec::from_fn(N) |_i| {
-        oldmap::HashMap::<node_id, ()>()
+    let mut graph = do vec::from_fn(N) |_i| {
+        LinearSet::new()
     };
 
     do vec::each(edges) |e| {
         match *e {
             (i, j) => {
-                oldmap::set_add(graph[i], j);
-                oldmap::set_add(graph[j], i);
+                graph[i].insert(j);
+                graph[j].insert(i);
             }
         }
         true
     }
 
-    do graph.map() |v| {
-        oldmap::vec_from_set(*v)
+    do vec::map_consume(graph) |mut v| {
+        let mut vec = ~[];
+        do v.consume |i| {
+            vec.push(i);
+        }
+        vec
     }
 }
 
 fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
-    let keys = oldmap::HashMap::<node_id, ()>();
+    let mut keys = LinearSet::new();
     let r = rand::Rng();
 
     while keys.len() < n {
@@ -111,10 +113,14 @@ fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
         if graph[k].len() > 0u && vec::any(graph[k], |i| {
             *i != k as node_id
         }) {
-            oldmap::set_add(keys, k as node_id);
+            keys.insert(k as node_id);
         }
     }
-    oldmap::vec_from_set(keys)
+    let mut vec = ~[];
+    do keys.consume |i| {
+        vec.push(i);
+    }
+    return vec;
 }
 
 /**
diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs
index 111219974d0..a81f7fd76e7 100644
--- a/src/test/bench/shootout-chameneos-redux.rs
+++ b/src/test/bench/shootout-chameneos-redux.rs
@@ -11,8 +11,6 @@
 // chameneos
 
 extern mod std;
-use std::oldmap;
-use std::oldmap::HashMap;
 use std::sort;
 use core::cell::Cell;
 use core::comm::*;
diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs
index f0847b635b4..f4ae799aace 100644
--- a/src/test/bench/shootout-k-nucleotide-pipes.rs
+++ b/src/test/bench/shootout-k-nucleotide-pipes.rs
@@ -14,15 +14,14 @@
 #[legacy_modes];
 
 extern mod std;
-use std::oldmap;
-use std::oldmap::HashMap;
 use std::sort;
+use core::hashmap::linear::LinearMap;
 use core::io::ReaderUtil;
 use core::comm::{stream, Port, Chan};
 use core::cmp::Ord;
 
 // given a map, print a sorted version of it
-fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
+fn sort_and_fmt(mm: &LinearMap<~[u8], uint>, total: uint) -> ~str {
    fn pct(xx: uint, yy: uint) -> float {
       return (xx as float) * 100f / (yy as float);
    }
@@ -49,7 +48,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
    let mut pairs = ~[];
 
    // map -> [(k,%)]
-   for mm.each |&key, &val| {
+   for mm.each |&(&key, &val)| {
       pairs.push((key, pct(val, total)));
    }
 
@@ -68,17 +67,21 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str {
 }
 
 // given a map, search for the frequency of a pattern
-fn find(mm: HashMap<~[u8], uint>, key: ~str) -> uint {
+fn find(mm: &LinearMap<~[u8], uint>, key: ~str) -> uint {
    match mm.find(&str::to_bytes(str::to_lower(key))) {
       option::None      => { return 0u; }
-      option::Some(num) => { return num; }
+      option::Some(&num) => { return num; }
    }
 }
 
 // given a map, increment the counter for a key
-fn update_freq(mm: HashMap<~[u8], uint>, key: &[u8]) {
+fn update_freq(mm: &mut LinearMap<~[u8], uint>, key: &[u8]) {
     let key = vec::slice(key, 0, key.len()).to_vec();
-    mm.update(key, 1, |v,v1| { v+v1 });
+    let newval = match mm.pop(&key) {
+        Some(v) => v + 1,
+        None => 1
+    };
+    mm.insert(key, newval);
 }
 
 // given a ~[u8], for each window call a function
@@ -100,7 +103,7 @@ fn windows_with_carry(bb: &[u8], nn: uint,
 fn make_sequence_processor(sz: uint, from_parent: comm::Port<~[u8]>,
                            to_parent: comm::Chan<~str>) {
 
-   let freqs: HashMap<~[u8], uint> = oldmap::HashMap();
+   let mut freqs: LinearMap<~[u8], uint> = LinearMap::new();
    let mut carry: ~[u8] = ~[];
    let mut total: uint = 0u;
 
@@ -112,19 +115,19 @@ fn make_sequence_processor(sz: uint, from_parent: comm::Port<~[u8]>,
       if line == ~[] { break; }
 
        carry = windows_with_carry(carry + line, sz, |window| {
-         update_freq(freqs, window);
+         update_freq(&mut freqs, window);
          total += 1u;
       });
    }
 
    let buffer = match sz {
-       1u => { sort_and_fmt(freqs, total) }
-       2u => { sort_and_fmt(freqs, total) }
-       3u => { fmt!("%u\t%s", find(freqs, ~"GGT"), ~"GGT") }
-       4u => { fmt!("%u\t%s", find(freqs, ~"GGTA"), ~"GGTA") }
-       6u => { fmt!("%u\t%s", find(freqs, ~"GGTATT"), ~"GGTATT") }
-      12u => { fmt!("%u\t%s", find(freqs, ~"GGTATTTTAATT"), ~"GGTATTTTAATT") }
-      18u => { fmt!("%u\t%s", find(freqs, ~"GGTATTTTAATTTATAGT"), ~"GGTATTTTAATTTATAGT") }
+       1u => { sort_and_fmt(&freqs, total) }
+       2u => { sort_and_fmt(&freqs, total) }
+       3u => { fmt!("%u\t%s", find(&freqs, ~"GGT"), ~"GGT") }
+       4u => { fmt!("%u\t%s", find(&freqs, ~"GGTA"), ~"GGTA") }
+       6u => { fmt!("%u\t%s", find(&freqs, ~"GGTATT"), ~"GGTATT") }
+      12u => { fmt!("%u\t%s", find(&freqs, ~"GGTATTTTAATT"), ~"GGTATTTTAATT") }
+      18u => { fmt!("%u\t%s", find(&freqs, ~"GGTATTTTAATTTATAGT"), ~"GGTATTTTAATTTATAGT") }
         _ => { ~"" }
    };
 
diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
index 07a68bfb068..6dbfa5dd538 100644
--- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
+++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
@@ -9,12 +9,12 @@
 // except according to those terms.
 
 //buggy.rs
-extern mod std;
-use std::oldmap::HashMap;
+
+use core::hashmap::linear::LinearMap;
 
 fn main() {
-    let buggy_map :HashMap<uint, &uint> =
-      HashMap::<uint, &uint>();
+    let mut buggy_map :LinearMap<uint, &uint> =
+      LinearMap::new::<uint, &uint>();
     buggy_map.insert(42, &*~1); //~ ERROR illegal borrow
 
     // but it is ok if we use a temporary
diff --git a/src/test/compile-fail/for-loop-decl.rs b/src/test/compile-fail/for-loop-decl.rs
index 952bf8c060a..918d8f00d78 100644
--- a/src/test/compile-fail/for-loop-decl.rs
+++ b/src/test/compile-fail/for-loop-decl.rs
@@ -10,11 +10,11 @@
 
 // error-pattern: mismatched types
 extern mod std;
-use std::oldmap::HashMap;
 use std::bitv;
+use core::hashmap::linear::LinearMap;
 
 struct FnInfo {
-    vars: HashMap<uint, VarInfo>
+    vars: LinearMap<uint, VarInfo>
 }
 
 struct VarInfo {
@@ -27,7 +27,7 @@ fn bitv_to_str(enclosing: FnInfo, v: ~bitv::Bitv) -> str {
 
     // error is that the value type in the hash map is var_info, not a box
     for enclosing.vars.each_value |val| {
-        if v.get(val) { s += "foo"; }
+        if *v.get(val) { s += "foo"; }
     }
     return s;
 }
diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs
index 2a7843bdccd..b6b2e004263 100644
--- a/src/test/run-pass/extern-mod-syntax.rs
+++ b/src/test/run-pass/extern-mod-syntax.rs
@@ -11,7 +11,7 @@
 // except according to those terms.
 
 extern mod std;
-use std::oldmap::HashMap;
+use std::json::Object;
 
 pub fn main() {
     io::println("Hello world!");
diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs
index 5d8ac2f1ab5..4234c064e8d 100644
--- a/src/test/run-pass/hashmap-memory.rs
+++ b/src/test/run-pass/hashmap-memory.rs
@@ -16,17 +16,10 @@
    This originally came from the word-count benchmark.
 */
 
-extern mod std;
-
-use std::oldmap;
-use std::oldmap::HashMap;
-use core::comm::*;
-
 pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
 
 mod map_reduce {
-    use std::oldmap;
-    use std::oldmap::HashMap;
+    use core::hashmap::linear::LinearMap;
     use core::comm::*;
 
     pub type putter = @fn(~str, ~str);
@@ -44,23 +37,20 @@ mod map_reduce {
     }
 
     fn map_task(ctrl: SharedChan<ctrl_proto>, input: ~str) {
-        let intermediates = oldmap::HashMap();
-
-        fn emit(im: oldmap::HashMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str,
-                val: ~str) {
-            let mut c;
-            match im.find(&key) {
-              Some(_c) => { c = _c }
-              None => {
-                  let (pp, cc) = stream();
-                error!("sending find_reducer");
-                ctrl.send(find_reducer(str::to_bytes(key), cc));
-                error!("receiving");
-                c = pp.recv();
-                error!(c);
-                im.insert(key, c);
-              }
+        let intermediates = @mut LinearMap::new();
+
+        fn emit(im: &mut LinearMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str,
+                _val: ~str) {
+            if im.contains_key(&key) {
+                return;
             }
+            let (pp, cc) = stream();
+            error!("sending find_reducer");
+            ctrl.send(find_reducer(str::to_bytes(key), cc));
+            error!("receiving");
+            let c = pp.recv();
+            error!(c);
+            im.insert(key, c);
         }
 
         let ctrl_clone = ctrl.clone();
@@ -75,9 +65,9 @@ mod map_reduce {
         // This task becomes the master control task. It spawns others
         // to do the rest.
 
-        let mut reducers: oldmap::HashMap<~str, int>;
+        let mut reducers: LinearMap<~str, int>;
 
-        reducers = oldmap::HashMap();
+        reducers = LinearMap::new();
 
         start_mappers(ctrl_chan, inputs.clone());
 
@@ -89,7 +79,7 @@ mod map_reduce {
               find_reducer(k, cc) => {
                 let mut c;
                 match reducers.find(&str::from_bytes(k)) {
-                  Some(_c) => { c = _c; }
+                  Some(&_c) => { c = _c; }
                   None => { c = 0; }
                 }
                 cc.send(c);
diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs
index 8697e5c8c3c..5f8b8d29830 100644
--- a/src/test/run-pass/issue-1696.rs
+++ b/src/test/run-pass/issue-1696.rs
@@ -10,11 +10,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
 
 pub fn main() {
-    let m = HashMap();
+    let mut m = LinearMap::new();
     m.insert(str::to_bytes(~"foo"), str::to_bytes(~"bar"));
     error!(m);
 }
diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs
index 5f5e2f9fc30..b22c423ed04 100644
--- a/src/test/run-pass/issue-2631-b.rs
+++ b/src/test/run-pass/issue-2631-b.rs
@@ -12,14 +12,13 @@
 // aux-build:issue-2631-a.rs
 
 extern mod req;
-extern mod std;
 
 use req::*;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
 
 pub fn main() {
   let v = ~[@~"hi"];
-  let m: req::header_map = HashMap();
+  let mut m: req::header_map = LinearMap::new();
   m.insert(~"METHOD", @mut v);
-  request::<int>(m);
+  request::<int>(&m);
 }
diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs
index 9fe88227c44..8934c3935c0 100644
--- a/src/test/run-pass/issue-2804-2.rs
+++ b/src/test/run-pass/issue-2804-2.rs
@@ -12,11 +12,11 @@
 
 // Minimized version of issue-2804.rs. Both check that callee IDs don't
 // clobber the previous node ID in a macro expr
-extern mod std;
-use std::oldmap::HashMap;
 
-fn add_interfaces(managed_ip: ~str, device: std::oldmap::HashMap<~str, int>)  {
-     error!("%s, %?", managed_ip, device[~"interfaces"]);
+use core::hashmap::linear::LinearMap;
+
+fn add_interfaces(managed_ip: ~str, device: LinearMap<~str, int>)  {
+     error!("%s, %?", managed_ip, device.get(&~"interfaces"));
 }
 
 pub fn main() {}
diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs
index 2b4acc34f46..3d1a2c3df5d 100644
--- a/src/test/run-pass/issue-2804.rs
+++ b/src/test/run-pass/issue-2804.rs
@@ -11,8 +11,7 @@
 // except according to those terms.
 
 extern mod std;
-use core::io::WriterUtil;
-use std::oldmap::HashMap;
+use core::hashmap::linear::LinearMap;
 use std::json;
 
 enum object {
@@ -59,19 +58,20 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str,
     }
 }
 
-fn add_interfaces(store: int, managed_ip: ~str, device: std::oldmap::HashMap<~str, std::json::Json>) -> ~[(~str, object)]
+fn add_interfaces(store: int, managed_ip: ~str, device: LinearMap<~str, std::json::Json>) -> ~[(~str, object)]
 {
-    match device[~"interfaces"]
+    match device.get(&~"interfaces")
     {
-        std::json::List(interfaces) =>
+        &std::json::List(ref interfaces) =>
         {
-          do vec::map(interfaces) |interface| {
+          do interfaces.map |interface| {
                 add_interface(store, copy managed_ip, copy *interface)
           }
         }
         _ =>
         {
-            error!("Expected list for %s interfaces but found %?", managed_ip, device[~"interfaces"]);
+            error!("Expected list for %s interfaces but found %?", managed_ip,
+                   device.get(&~"interfaces"));
             ~[]
         }
     }
diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs
index 32f7d2ee07c..022d3f6fceb 100644
--- a/src/test/run-pass/issue-3026.rs
+++ b/src/test/run-pass/issue-3026.rs
@@ -10,12 +10,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
-use std::oldmap::HashMap;
-use std::oldmap;
+use core::hashmap::linear::LinearMap;
 
 pub fn main() {
-    let buggy_map :HashMap<uint, &uint> = HashMap::<uint, &uint>();
+    let mut buggy_map: LinearMap<uint, &uint> = LinearMap::new::<uint, &uint>();
     let x = ~1;
     buggy_map.insert(42, &*x);
 }
diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs
index 0486357dc69..46a02ff1592 100644
--- a/src/test/run-pass/issue-3559.rs
+++ b/src/test/run-pass/issue-3559.rs
@@ -14,7 +14,6 @@
 extern mod std;
 
 use core::io::{WriterUtil};
-use std::oldmap::*;
 
 #[cfg(test)]
 fn check_strs(actual: &str, expected: &str) -> bool
@@ -30,7 +29,7 @@ fn check_strs(actual: &str, expected: &str) -> bool
 #[test]
 fn tester()
 {
-    let table = HashMap();
+    let mut table = core::hashmap::linear::LinearMap();
     table.insert(@~"one", 1);
     table.insert(@~"two", 2);
     fail_unless!(check_strs(table.to_str(), ~"xxx"));   // not sure what expected should be
diff --git a/src/test/run-pass/issue-4092.rs b/src/test/run-pass/issue-4092.rs
index 5cfb5809feb..85cb3e3207e 100644
--- a/src/test/run-pass/issue-4092.rs
+++ b/src/test/run-pass/issue-4092.rs
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-extern mod std;
+use core::hashmap::linear::LinearMap;
 
 pub fn main() {
-    let x = std::oldmap::HashMap();
+    let mut x = LinearMap::new();
     x.insert((@"abc", 0), 0);
 }