From 9aec7a3e85c5b07923eab05d3ebe9d031bf258f3 Mon Sep 17 00:00:00 2001 From: Simon BD Date: Mon, 22 Oct 2012 18:33:28 -0500 Subject: [PATCH] Fix up tests, export tim_sort --- src/libstd/sort.rs | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 7bafb324dad0..98f98fe7fce6 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -166,7 +166,7 @@ const MIN_MERGE: uint = 64; const MIN_GALLOP: uint = 7; const INITIAL_TMP_STORAGE: uint = 128; -fn tim_sort(array: &[mut T]) { +pub fn tim_sort(array: &[mut T]) { let size = array.len(); if size < 2 { return; @@ -977,7 +977,7 @@ mod tests { #[cfg(test)] mod test_tim_sort { - #[legacy_exports]; + // #[legacy_exports]; struct CVal { val: ~float, } @@ -1046,10 +1046,10 @@ mod test_tim_sort { struct DVal { val: ~uint } impl DVal: Ord { - pure fn lt(other: &DVal) -> bool { true } - pure fn le(other: &DVal) -> bool { true } - pure fn gt(other: &DVal) -> bool { true } - pure fn ge(other: &DVal) -> bool { true } + pure fn lt(_x: &DVal) -> bool { true } + pure fn le(_x: &DVal) -> bool { true } + pure fn gt(_x: &DVal) -> bool { true } + pure fn ge(_x: &DVal) -> bool { true } } #[test] @@ -1066,16 +1066,11 @@ mod test_tim_sort { } } -/*fn f(array: &[mut T]) { array[0] <-> array[0] } - -fn ice_test() { - let _s1 = &fn(arr: &[mut ~float]) { tim_sort(arr); }; -}*/ - -//#[cfg(test)] +/* +#[cfg(test)] mod big_tests { - //#[test] + #[test] fn sorts_test() { let low = 5; let high = 10; @@ -1091,9 +1086,9 @@ mod big_tests { // Run tabulate_unique and tabulate_managed // with the other sorts at some point - //tabulate_unique(low, high); - //tabulate_managed(low, high); - //tabulate_linear(low, high); + tabulate_unique(low, high); + tabulate_managed(low, high); + tabulate_linear(); } fn multiplyVec(arr: &[const T], num: uint) -> ~[mut T] { @@ -1111,7 +1106,7 @@ mod big_tests { vec::append(two, one) } - /*fn tabulate_unique(lo: uint, hi: uint) { + fn tabulate_unique(lo: uint, hi: uint) { fn isSorted(arr: &[const T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { @@ -1181,9 +1176,9 @@ mod big_tests { tim_sort(arr); // !sort isSorted(arr); } - }*/ + } - /*fn tabulate_managed(lo: uint, hi: uint) { + fn tabulate_managed(lo: uint, hi: uint) { fn isSorted(arr: &[const @T], expected_refcount: uint) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { @@ -1255,8 +1250,7 @@ mod big_tests { isSorted(arr, 2); } } -*/ -/* + struct LVal { val: uint, key: fn(@uint), @@ -1281,8 +1275,8 @@ mod big_tests { pure fn ge(other: &LVal) -> bool { self.val >= other.val } } - fn tabulate_linear(lo: uint, hi: uint) { - fn key(+_x: @uint) { } + fn tabulate_linear() { + fn key(_x: @uint) { } fn isSorted(arr: &[const T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { @@ -1310,8 +1304,8 @@ mod big_tests { assert n == dropped; } - */ } +*/ // Local Variables: // mode: rust;