Fix broken tests

This commit is contained in:
Brian Anderson 2012-09-10 15:35:37 -07:00
parent 7e9f98a8c9
commit 10aa849d28
2 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ use std::map::hashmap;
use std::sort;
use io::ReaderUtil;
use pipes::{stream, Port, Chan};
use cmp::Ord;
// given a map, print a sorted version of it
fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
@ -15,14 +16,14 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
return (xx as float) * 100f / (yy as float);
}
pure fn le_by_val<TT: Copy, UU: Copy>(kv0: &(TT,UU),
pure fn le_by_val<TT: Copy, UU: Copy Ord>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (_, v0) = *kv0;
let (_, v1) = *kv1;
return v0 >= v1;
}
pure fn le_by_key<TT: Copy, UU: Copy>(kv0: &(TT,UU),
pure fn le_by_key<TT: Copy Ord, UU: Copy>(kv0: &(TT,UU),
kv1: &(TT,UU)) -> bool {
let (k0, _) = *kv0;
let (k1, _) = *kv1;
@ -30,7 +31,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
}
// sort by key, then by value
fn sortKV<TT: Copy, UU: Copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
fn sortKV<TT: Copy Ord, UU: Copy Ord>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] {
return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig));
}

View File

@ -7,6 +7,7 @@ use std::map;
use std::map::hashmap;
use std::sort;
use io::ReaderUtil;
use cmp::Ord;
// given a map, print a sorted version of it
fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {