Skip to content

Unstub some tests #24929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/libcoretest/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ fn test_ord() {
assert!(big > None);
}

/* FIXME(#20575)
#[test]
fn test_collect() {
let v: Option<Vec<isize>> = (0..0).map(|_| Some(0)).collect();
Expand All @@ -241,28 +240,26 @@ fn test_collect() {

assert!(v == None);
}
*/


#[test]
fn test_cloned() {
let val1 = 1u32;
let mut val2 = 2u32;
let val1_ref = &val1;
let val = 1u32;
let val_ref = &val;
let opt_none: Option<&'static u32> = None;
let opt_ref = Some(&val1);
let opt_ref_ref = Some(&val1_ref);
let opt_mut_ref = Some(&mut val2);
let opt_ref = Some(&val);
let opt_ref_ref = Some(&val_ref);

// None works
assert_eq!(opt_none.clone(), None);
assert_eq!(opt_none.cloned(), None);

// Immutable ref works
assert_eq!(opt_ref.clone(), Some(&val1));
assert_eq!(opt_ref.clone(), Some(&val));
assert_eq!(opt_ref.cloned(), Some(1u32));

// Double Immutable ref works
assert_eq!(opt_ref_ref.clone(), Some(&val1_ref));
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val1));
assert_eq!(opt_ref_ref.clone(), Some(&val_ref));
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val));
assert_eq!(opt_ref_ref.cloned().cloned(), Some(1u32));
}
24 changes: 11 additions & 13 deletions src/libcoretest/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub fn op1() -> Result<isize, &'static str> { Ok(666) }
pub fn op2() -> Result<isize, &'static str> { Err("sadface") }
fn op1() -> Result<isize, &'static str> { Ok(666) }
fn op2() -> Result<isize, &'static str> { Err("sadface") }

#[test]
pub fn test_and() {
fn test_and() {
assert_eq!(op1().and(Ok(667)).unwrap(), 667);
assert_eq!(op1().and(Err::<i32, &'static str>("bad")).unwrap_err(),
"bad");
Expand All @@ -23,7 +23,7 @@ pub fn test_and() {
}

#[test]
pub fn test_and_then() {
fn test_and_then() {
assert_eq!(op1().and_then(|i| Ok::<isize, &'static str>(i + 1)).unwrap(), 667);
assert_eq!(op1().and_then(|_| Err::<isize, &'static str>("bad")).unwrap_err(),
"bad");
Expand All @@ -35,7 +35,7 @@ pub fn test_and_then() {
}

#[test]
pub fn test_or() {
fn test_or() {
assert_eq!(op1().or(Ok::<_, &'static str>(667)).unwrap(), 666);
assert_eq!(op1().or(Err("bad")).unwrap(), 666);

Expand All @@ -44,7 +44,7 @@ pub fn test_or() {
}

#[test]
pub fn test_or_else() {
fn test_or_else() {
assert_eq!(op1().or_else(|_| Ok::<isize, &'static str>(667)).unwrap(), 666);
assert_eq!(op1().or_else(|e| Err::<isize, &'static str>(e)).unwrap(), 666);

Expand All @@ -54,18 +54,17 @@ pub fn test_or_else() {
}

#[test]
pub fn test_impl_map() {
fn test_impl_map() {
assert!(Ok::<isize, isize>(1).map(|x| x + 1) == Ok(2));
assert!(Err::<isize, isize>(1).map(|x| x + 1) == Err(1));
}

#[test]
pub fn test_impl_map_err() {
fn test_impl_map_err() {
assert!(Ok::<isize, isize>(1).map_err(|x| x + 1) == Ok(1));
assert!(Err::<isize, isize>(1).map_err(|x| x + 1) == Err(2));
}

/* FIXME(#20575)
#[test]
fn test_collect() {
let v: Result<Vec<isize>, ()> = (0..0).map(|_| Ok::<isize, ()>(0)).collect();
Expand All @@ -86,10 +85,9 @@ fn test_collect() {
let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();
assert!(v == Err(1));
}
*/

#[test]
pub fn test_fmt_default() {
fn test_fmt_default() {
let ok: Result<isize, &'static str> = Ok(100);
let err: Result<isize, &'static str> = Err("Err");

Expand All @@ -100,7 +98,7 @@ pub fn test_fmt_default() {
}

#[test]
pub fn test_unwrap_or() {
fn test_unwrap_or() {
let ok: Result<isize, &'static str> = Ok(100);
let ok_err: Result<isize, &'static str> = Err("Err");

Expand All @@ -109,7 +107,7 @@ pub fn test_unwrap_or() {
}

#[test]
pub fn test_unwrap_or_else() {
fn test_unwrap_or_else() {
fn handler(msg: &'static str) -> isize {
if msg == "I got this." {
50
Expand Down