Skip to content

Commit 9aec7a3

Browse files
committed
Fix up tests, export tim_sort
1 parent 0e3bec0 commit 9aec7a3

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/libstd/sort.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const MIN_MERGE: uint = 64;
166166
const MIN_GALLOP: uint = 7;
167167
const INITIAL_TMP_STORAGE: uint = 128;
168168

169-
fn tim_sort<T: Ord>(array: &[mut T]) {
169+
pub fn tim_sort<T: Ord>(array: &[mut T]) {
170170
let size = array.len();
171171
if size < 2 {
172172
return;
@@ -977,7 +977,7 @@ mod tests {
977977

978978
#[cfg(test)]
979979
mod test_tim_sort {
980-
#[legacy_exports];
980+
// #[legacy_exports];
981981
struct CVal {
982982
val: ~float,
983983
}
@@ -1046,10 +1046,10 @@ mod test_tim_sort {
10461046

10471047
struct DVal { val: ~uint }
10481048
impl DVal: Ord {
1049-
pure fn lt(other: &DVal) -> bool { true }
1050-
pure fn le(other: &DVal) -> bool { true }
1051-
pure fn gt(other: &DVal) -> bool { true }
1052-
pure fn ge(other: &DVal) -> bool { true }
1049+
pure fn lt(_x: &DVal) -> bool { true }
1050+
pure fn le(_x: &DVal) -> bool { true }
1051+
pure fn gt(_x: &DVal) -> bool { true }
1052+
pure fn ge(_x: &DVal) -> bool { true }
10531053
}
10541054

10551055
#[test]
@@ -1066,16 +1066,11 @@ mod test_tim_sort {
10661066
}
10671067
}
10681068

1069-
/*fn f<T: Ord>(array: &[mut T]) { array[0] <-> array[0] }
1070-
1071-
fn ice_test() {
1072-
let _s1 = &fn(arr: &[mut ~float]) { tim_sort(arr); };
1073-
}*/
1074-
1075-
//#[cfg(test)]
1069+
/*
1070+
#[cfg(test)]
10761071
mod big_tests {
10771072
1078-
//#[test]
1073+
#[test]
10791074
fn sorts_test() {
10801075
let low = 5;
10811076
let high = 10;
@@ -1091,9 +1086,9 @@ mod big_tests {
10911086
10921087
// Run tabulate_unique and tabulate_managed
10931088
// with the other sorts at some point
1094-
//tabulate_unique(low, high);
1095-
//tabulate_managed(low, high);
1096-
//tabulate_linear(low, high);
1089+
tabulate_unique(low, high);
1090+
tabulate_managed(low, high);
1091+
tabulate_linear();
10971092
}
10981093
10991094
fn multiplyVec<T: Copy>(arr: &[const T], num: uint) -> ~[mut T] {
@@ -1111,7 +1106,7 @@ mod big_tests {
11111106
vec::append(two, one)
11121107
}
11131108
1114-
/*fn tabulate_unique(lo: uint, hi: uint) {
1109+
fn tabulate_unique(lo: uint, hi: uint) {
11151110
fn isSorted<T: Ord>(arr: &[const T]) {
11161111
for uint::range(0, arr.len()-1) |i| {
11171112
if arr[i] > arr[i+1] {
@@ -1181,9 +1176,9 @@ mod big_tests {
11811176
tim_sort(arr); // !sort
11821177
isSorted(arr);
11831178
}
1184-
}*/
1179+
}
11851180
1186-
/*fn tabulate_managed(lo: uint, hi: uint) {
1181+
fn tabulate_managed(lo: uint, hi: uint) {
11871182
fn isSorted<T: Ord>(arr: &[const @T], expected_refcount: uint) {
11881183
for uint::range(0, arr.len()-1) |i| {
11891184
if arr[i] > arr[i+1] {
@@ -1255,8 +1250,7 @@ mod big_tests {
12551250
isSorted(arr, 2);
12561251
}
12571252
}
1258-
*/
1259-
/*
1253+
12601254
struct LVal {
12611255
val: uint,
12621256
key: fn(@uint),
@@ -1281,8 +1275,8 @@ mod big_tests {
12811275
pure fn ge(other: &LVal) -> bool { self.val >= other.val }
12821276
}
12831277
1284-
fn tabulate_linear(lo: uint, hi: uint) {
1285-
fn key(+_x: @uint) { }
1278+
fn tabulate_linear() {
1279+
fn key(_x: @uint) { }
12861280
fn isSorted<T: Ord>(arr: &[const T]) {
12871281
for uint::range(0, arr.len()-1) |i| {
12881282
if arr[i] > arr[i+1] {
@@ -1310,8 +1304,8 @@ mod big_tests {
13101304
13111305
assert n == dropped;
13121306
}
1313-
*/
13141307
}
1308+
*/
13151309

13161310
// Local Variables:
13171311
// mode: rust;

0 commit comments

Comments
 (0)