Skip to content

Commit 18251ee

Browse files
author
Keegan McAllister
committed
libcollections test suite fixes
1 parent e17977f commit 18251ee

File tree

6 files changed

+39
-27
lines changed

6 files changed

+39
-27
lines changed

src/libcollections/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extern crate alloc;
3030
#[cfg(test)] extern crate native;
3131
#[cfg(test)] extern crate test;
3232
#[cfg(test)] extern crate debug;
33+
#[cfg(test)] extern crate std;
3334

34-
#[cfg(test)] #[phase(plugin, link)] extern crate std;
3535
#[cfg(test)] #[phase(plugin, link)] extern crate log;
3636

3737
use core::prelude::Option;

src/libcollections/slice.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,12 @@ pub mod raw {
742742

743743
#[cfg(test)]
744744
mod tests {
745+
use core::prelude::*;
746+
use alloc::boxed::Box;
747+
use collections::string::String;
745748
use std::cell::Cell;
746749
use std::default::Default;
747750
use std::mem;
748-
use std::prelude::*;
749751
use std::rand::{Rng, task_rng};
750752
use std::rc::Rc;
751753
use std::rt;
@@ -1183,7 +1185,7 @@ mod tests {
11831185
assert_eq!(it.next(), None);
11841186
}
11851187
{
1186-
let v = ["Hello".to_string()];
1188+
let v = [String::from_str("Hello")];
11871189
let mut it = v.permutations();
11881190
let (min_size, max_opt) = it.size_hint();
11891191
assert_eq!(min_size, 1);
@@ -1925,20 +1927,20 @@ mod tests {
19251927
})
19261928
)
19271929
let empty: Vec<int> = vec![];
1928-
test_show_vec!(empty, "[]".to_string());
1929-
test_show_vec!(vec![1i], "[1]".to_string());
1930-
test_show_vec!(vec![1i, 2, 3], "[1, 2, 3]".to_string());
1930+
test_show_vec!(empty, String::from_str("[]"));
1931+
test_show_vec!(vec![1i], String::from_str("[1]"));
1932+
test_show_vec!(vec![1i, 2, 3], String::from_str("[1, 2, 3]"));
19311933
test_show_vec!(vec![vec![], vec![1u], vec![1u, 1u]],
1932-
"[[], [1], [1, 1]]".to_string());
1934+
String::from_str("[[], [1], [1, 1]]"));
19331935

19341936
let empty_mut: &mut [int] = &mut[];
1935-
test_show_vec!(empty_mut, "[]".to_string());
1937+
test_show_vec!(empty_mut, String::from_str("[]"));
19361938
let v: &mut[int] = &mut[1];
1937-
test_show_vec!(v, "[1]".to_string());
1939+
test_show_vec!(v, String::from_str("[1]"));
19381940
let v: &mut[int] = &mut[1, 2, 3];
1939-
test_show_vec!(v, "[1, 2, 3]".to_string());
1941+
test_show_vec!(v, String::from_str("[1, 2, 3]"));
19401942
let v: &mut [&mut[uint]] = &mut[&mut[], &mut[1u], &mut[1u, 1u]];
1941-
test_show_vec!(v, "[[], [1], [1, 1]]".to_string());
1943+
test_show_vec!(v, String::from_str("[[], [1], [1, 1]]"));
19421944
}
19431945

19441946
#[test]

src/libcollections/smallintmap.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,13 @@ pub type Values<'a, T> =
520520

521521
#[cfg(test)]
522522
mod test_map {
523-
use std::prelude::*;
523+
use core::prelude::*;
524524
use vec::Vec;
525525
use hash;
526526

527527
use {Map, MutableMap, Mutable, MutableSeq};
528528
use super::SmallIntMap;
529+
use string::String;
529530

530531
#[test]
531532
fn test_find_mut() {
@@ -764,6 +765,8 @@ mod test_map {
764765

765766
#[test]
766767
fn test_show() {
768+
use std::to_string::ToString;
769+
767770
let mut map = SmallIntMap::new();
768771
let empty = SmallIntMap::<int>::new();
769772

@@ -773,7 +776,7 @@ mod test_map {
773776
let map_str = map.to_string();
774777
let map_str = map_str.as_slice();
775778
assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
776-
assert_eq!(format!("{}", empty), "{}".to_string());
779+
assert_eq!(format!("{}", empty), String::from_str("{}"));
777780
}
778781

779782
#[test]

src/libcollections/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ pub mod raw {
890890

891891
#[cfg(test)]
892892
mod tests {
893-
use std::prelude::*;
893+
use core::prelude::*;
894894
use test::Bencher;
895895

896896
use {Mutable, MutableSeq};
@@ -901,7 +901,7 @@ mod tests {
901901

902902
#[test]
903903
fn test_from_str() {
904-
let owned: Option<::std::string::String> = from_str("string");
904+
let owned: Option<::string::String> = Some(String::from_str("string"));
905905
assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
906906
}
907907

src/libcollections/treemap.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1669,12 +1669,15 @@ impl<S: Writer, T: Ord + Hash<S>> Hash<S> for TreeSet<T> {
16691669

16701670
#[cfg(test)]
16711671
mod test_treemap {
1672-
use std::prelude::*;
1672+
use core::prelude::*;
1673+
use alloc::boxed::Box;
16731674
use std::rand::Rng;
16741675
use std::rand;
16751676

16761677
use {Map, MutableMap, Mutable, MutableSeq};
16771678
use super::{TreeMap, TreeNode};
1679+
use vec::Vec;
1680+
use string::String;
16781681

16791682
#[test]
16801683
fn find_empty() {
@@ -2099,8 +2102,8 @@ mod test_treemap {
20992102

21002103
let map_str = format!("{}", map);
21012104

2102-
assert!(map_str == "{1: 2, 3: 4}".to_string());
2103-
assert_eq!(format!("{}", empty), "{}".to_string());
2105+
assert!(map_str == String::from_str("{1: 2, 3: 4}"));
2106+
assert_eq!(format!("{}", empty), String::from_str("{}"));
21042107
}
21052108

21062109
#[test]
@@ -2247,11 +2250,12 @@ mod bench {
22472250

22482251
#[cfg(test)]
22492252
mod test_set {
2250-
use std::prelude::*;
2253+
use core::prelude::*;
22512254

22522255
use {Set, MutableSet, Mutable, MutableMap, MutableSeq};
22532256
use super::{TreeMap, TreeSet};
22542257
use hash;
2258+
use string::String;
22552259

22562260
#[test]
22572261
fn test_clear() {
@@ -2550,7 +2554,7 @@ mod test_set {
25502554

25512555
let set_str = format!("{}", set);
25522556

2553-
assert!(set_str == "{1, 2}".to_string());
2554-
assert_eq!(format!("{}", empty), "{}".to_string());
2557+
assert!(set_str == String::from_str("{1, 2}"));
2558+
assert_eq!(format!("{}", empty), String::from_str("{}"));
25552559
}
25562560
}

src/libcollections/trie.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1016,13 +1016,15 @@ impl<'a> Iterator<uint> for SetItems<'a> {
10161016

10171017
#[cfg(test)]
10181018
mod test_map {
1019-
use std::prelude::*;
1019+
use core::prelude::*;
10201020
use std::iter::range_step;
10211021
use std::uint;
10221022

10231023
use {MutableMap, Map, MutableSeq};
10241024
use super::{TrieMap, TrieNode, Internal, External, Nothing};
10251025
use hash;
1026+
use vec::Vec;
1027+
use string::String;
10261028

10271029
fn check_integrity<T>(trie: &TrieNode<T>) {
10281030
assert!(trie.count != 0);
@@ -1403,8 +1405,8 @@ mod test_map {
14031405

14041406
let map_str = format!("{}", map);
14051407

1406-
assert!(map_str == "{1: a, 2: b}".to_string());
1407-
assert_eq!(format!("{}", empty), "{}".to_string());
1408+
assert!(map_str == String::from_str("{1: a, 2: b}"));
1409+
assert_eq!(format!("{}", empty), String::from_str("{}"));
14081410
}
14091411

14101412
#[test]
@@ -1543,7 +1545,8 @@ mod bench_map {
15431545

15441546
#[cfg(test)]
15451547
mod test_set {
1546-
use std::prelude::*;
1548+
use core::prelude::*;
1549+
use collections::string::String;
15471550
use std::uint;
15481551

15491552
use {MutableSet, Set, MutableSeq};
@@ -1589,8 +1592,8 @@ mod test_set {
15891592

15901593
let set_str = format!("{}", set);
15911594

1592-
assert!(set_str == "{1, 2}".to_string());
1593-
assert_eq!(format!("{}", empty), "{}".to_string());
1595+
assert!(set_str == String::from_str("{1, 2}"));
1596+
assert_eq!(format!("{}", empty), String::from_str("{}"));
15941597
}
15951598

15961599
#[test]

0 commit comments

Comments
 (0)