Use arrays instead of vectors in tests

This commit is contained in:
Vadim Petrochenkov 2015-02-24 21:15:45 +03:00
parent dccdde4007
commit 2807a1ce02
41 changed files with 254 additions and 267 deletions

View file

@ -23,5 +23,5 @@ pub fn main() {
let mut v = vec!(1);
v.push_val(2);
v.push_val(3);
assert_eq!(v, vec!(1, 2, 3));
assert_eq!(v, [1, 2, 3]);
}

View file

@ -22,5 +22,5 @@ fn bar(v: &mut [uint]) {
pub fn main() {
let mut the_vec = vec!(1, 2, 3, 100);
bar(&mut the_vec);
assert_eq!(the_vec, vec!(100, 3, 2, 1));
assert_eq!(the_vec, [100, 3, 2, 1]);
}

View file

@ -18,5 +18,5 @@ fn bar(v: &mut [uint]) {
pub fn main() {
let mut the_vec = vec!(1, 2, 3, 100);
bar(&mut the_vec);
assert_eq!(the_vec, vec!(100, 3, 2, 1));
assert_eq!(the_vec, [100, 3, 2, 1]);
}

View file

@ -24,5 +24,5 @@ impl<T> vec_utils<T> for Vec<T> {
}
pub fn main() {
assert_eq!(vec_utils::map_(&vec!(1,2,3), |&x| x+1), vec!(2,3,4));
assert_eq!(vec_utils::map_(&vec!(1,2,3), |&x| x+1), [2,3,4]);
}

View file

@ -44,11 +44,11 @@ fn transform(x: Option<int>) -> Option<String> {
pub fn main() {
assert_eq!(transform(Some(10)), Some("11".to_string()));
assert_eq!(transform(None), None);
assert!((vec!("hi".to_string()))
assert_eq!((vec!("hi".to_string()))
.bind(|x| vec!(x.clone(), format!("{}!", x)) )
.bind(|x| vec!(x.clone(), format!("{}?", x)) ) ==
vec!("hi".to_string(),
"hi?".to_string(),
"hi!".to_string(),
"hi!?".to_string()));
.bind(|x| vec!(x.clone(), format!("{}?", x)) ),
["hi".to_string(),
"hi?".to_string(),
"hi!".to_string(),
"hi!?".to_string()]);
}

View file

@ -44,9 +44,9 @@ fn bar<U:to_str,T:map<U>>(x: T) -> Vec<String> {
}
pub fn main() {
assert_eq!(foo(vec!(1)), vec!("hi".to_string()));
assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), vec!("4".to_string(), "5".to_string()));
assert_eq!(foo(vec!(1)), ["hi".to_string()]);
assert_eq!(bar::<int, Vec<int> >(vec!(4, 5)), ["4".to_string(), "5".to_string()]);
assert_eq!(bar::<String, Vec<String> >(vec!("x".to_string(), "y".to_string())),
vec!("x".to_string(), "y".to_string()));
assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!("()".to_string()));
["x".to_string(), "y".to_string()]);
assert_eq!(bar::<(), Vec<()>>(vec!(())), ["()".to_string()]);
}

View file

@ -18,5 +18,5 @@ fn f<F: FnMut()>(mut f: F) {
fn main() {
let mut v: Vec<_> = vec![];
f(|| v.push(0));
assert_eq!(v, vec![0]);
assert_eq!(v, [0]);
}