diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-14 23:05:01 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-19 12:59:40 -0700 |
| commit | 9d5d97b55d6487ee23b805bc1acbaa0669b82116 (patch) | |
| tree | b72dcf7045e331e94ea0f8658d088ab42d917935 /src/libcoretest | |
| parent | fb169d5543c84e11038ba2d07b538ec88fb49ca6 (diff) | |
| download | rust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.tar.gz rust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.zip | |
Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/cmp.rs | 16 | ||||
| -rw-r--r-- | src/libcoretest/option.rs | 53 | ||||
| -rw-r--r-- | src/libcoretest/ptr.rs | 132 | ||||
| -rw-r--r-- | src/libcoretest/result.rs | 35 |
4 files changed, 25 insertions, 211 deletions
diff --git a/src/libcoretest/cmp.rs b/src/libcoretest/cmp.rs index 4ac3f7e9310..59ce73fe40d 100644 --- a/src/libcoretest/cmp.rs +++ b/src/libcoretest/cmp.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::cmp::lexical_ordering; use core::cmp::{ partial_min, partial_max }; #[test] @@ -43,21 +42,6 @@ fn test_ordering_order() { } #[test] -#[allow(deprecated)] -fn test_lexical_ordering() { - fn t(o1: Ordering, o2: Ordering, e: Ordering) { - assert_eq!(lexical_ordering(o1, o2), e); - } - - let xs = [Less, Equal, Greater]; - for &o in xs.iter() { - t(Less, o, Less); - t(Equal, o, o); - t(Greater, o, Greater); - } -} - -#[test] fn test_partial_min() { use core::f64::NAN; let data_integer = [ diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 3f150b3d136..71e9270fe4b 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -131,21 +131,6 @@ fn test_or_else() { } #[test] -#[allow(deprecated)] -fn test_option_while_some() { - let mut i = 0i; - Some(10i).while_some(|j| { - i += 1; - if j > 0 { - Some(j-1) - } else { - None - } - }); - assert_eq!(i, 11); -} - -#[test] fn test_unwrap() { assert_eq!(Some(1i).unwrap(), 1); let s = Some("hello".to_string()).unwrap(); @@ -185,15 +170,6 @@ fn test_unwrap_or_else() { } #[test] -#[allow(deprecated)] -fn test_filtered() { - let some_stuff = Some(42i); - let modified_stuff = some_stuff.filtered(|&x| {x < 10}); - assert_eq!(some_stuff.unwrap(), 42); - assert!(modified_stuff.is_none()); -} - -#[test] fn test_iter() { let val = 5i; @@ -244,39 +220,22 @@ fn test_ord() { } #[test] -#[allow(deprecated)] -fn test_mutate() { - let mut x = Some(3i); - assert!(x.mutate(|i| i+1)); - assert_eq!(x, Some(4i)); - assert!(x.mutate_or_set(0, |i| i+1)); - assert_eq!(x, Some(5i)); - x = None; - assert!(!x.mutate(|i| i+1)); - assert_eq!(x, None); - assert!(!x.mutate_or_set(0i, |i| i+1)); - assert_eq!(x, Some(0i)); -} - -#[test] -#[allow(deprecated)] fn test_collect() { - let v: Option<Vec<int>> = collect(range(0i, 0) - .map(|_| Some(0i))); + let v: Option<Vec<int>> = range(0i, 0).map(|_| Some(0i)).collect(); assert!(v == Some(vec![])); - let v: Option<Vec<int>> = collect(range(0i, 3) - .map(|x| Some(x))); + let v: Option<Vec<int>> = range(0i, 3).map(|x| Some(x)).collect(); assert!(v == Some(vec![0, 1, 2])); - let v: Option<Vec<int>> = collect(range(0i, 3) - .map(|x| if x > 1 { None } else { Some(x) })); + let v: Option<Vec<int>> = range(0i, 3).map(|x| { + if x > 1 { None } else { Some(x) } + }).collect(); assert!(v == None); // test that it does not take more elements than it needs let mut functions = [|| Some(()), || None, || fail!()]; - let v: Option<Vec<()>> = collect(functions.iter_mut().map(|f| (*f)())); + let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == None); } diff --git a/src/libcoretest/ptr.rs b/src/libcoretest/ptr.rs index 754391a284d..db3580e5d0c 100644 --- a/src/libcoretest/ptr.rs +++ b/src/libcoretest/ptr.rs @@ -7,12 +7,9 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(deprecated)] + use core::ptr::*; -use libc::c_char; use core::mem; -use libc; -use std::c_str::CString; #[test] fn test() { @@ -39,50 +36,23 @@ fn test() { copy_memory(v1.as_mut_ptr().offset(1), v0.as_ptr().offset(1), 1); - assert!((*v1.get(0) == 0u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 0u16)); + assert!((v1[0] == 0u16 && + v1[1] == 32001u16 && + v1[2] == 0u16)); copy_memory(v1.as_mut_ptr(), v0.as_ptr().offset(2), 1); - assert!((*v1.get(0) == 32002u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 0u16)); + assert!((v1[0] == 32002u16 && + v1[1] == 32001u16 && + v1[2] == 0u16)); copy_memory(v1.as_mut_ptr().offset(2), v0.as_ptr(), 1u); - assert!((*v1.get(0) == 32002u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 32000u16)); + assert!((v1[0] == 32002u16 && + v1[1] == 32001u16 && + v1[2] == 32000u16)); } } #[test] -fn test_position() { - use libc::c_char; - - "hello".with_c_str(|p| { - unsafe { - assert!(2u == position(p, |c| *c == 'l' as c_char)); - assert!(4u == position(p, |c| *c == 'o' as c_char)); - assert!(5u == position(p, |c| *c == 0 as c_char)); - } - }) -} - -#[test] -fn test_buf_len() { - "hello".with_c_str(|p0| { - "there".with_c_str(|p1| { - "thing".with_c_str(|p2| { - let v = vec![p0, p1, p2, null()]; - unsafe { - assert_eq!(buf_len(v.as_ptr()), 3u); - } - }) - }) - }) -} - -#[test] fn test_is_null() { let p: *const int = null(); assert!(p.is_null()); @@ -92,7 +62,7 @@ fn test_is_null() { assert!(!q.is_null()); assert!(q.is_not_null()); - let mp: *mut int = mut_null(); + let mp: *mut int = null_mut(); assert!(mp.is_null()); assert!(!mp.is_not_null()); @@ -110,7 +80,7 @@ fn test_as_ref() { let q: *const int = &2; assert_eq!(q.as_ref().unwrap(), &2); - let p: *mut int = mut_null(); + let p: *mut int = null_mut(); assert_eq!(p.as_ref(), None); let q: *mut int = &mut 2; @@ -128,7 +98,7 @@ fn test_as_ref() { #[test] fn test_as_mut() { unsafe { - let p: *mut int = mut_null(); + let p: *mut int = null_mut(); assert!(p.as_mut() == None); let q: *mut int = &mut 2; @@ -194,82 +164,6 @@ fn test_ptr_subtraction() { } #[test] -fn test_ptr_array_each_with_len() { - unsafe { - let one = "oneOne".to_c_str(); - let two = "twoTwo".to_c_str(); - let three = "threeThree".to_c_str(); - let arr = vec![ - one.as_ptr(), - two.as_ptr(), - three.as_ptr() - ]; - let expected_arr = [ - one, two, three - ]; - - let mut ctr = 0; - let mut iteration_count = 0; - array_each_with_len(arr.as_ptr(), arr.len(), |e| { - let actual = CString::new(e, false); - assert_eq!(actual.as_str(), expected_arr[ctr].as_str()); - ctr += 1; - iteration_count += 1; - }); - assert_eq!(iteration_count, 3u); - } -} - -#[test] -fn test_ptr_array_each() { - unsafe { - let one = "oneOne".to_c_str(); - let two = "twoTwo".to_c_str(); - let three = "threeThree".to_c_str(); - let arr = vec![ - one.as_ptr(), - two.as_ptr(), - three.as_ptr(), - // fake a null terminator - null() - ]; - let expected_arr = [ - one, two, three - ]; - - let arr_ptr = arr.as_ptr(); - let mut ctr = 0u; - let mut iteration_count = 0u; - array_each(arr_ptr, |e| { - let actual = CString::new(e, false); - assert_eq!(actual.as_str(), expected_arr[ctr].as_str()); - ctr += 1; - iteration_count += 1; - }); - assert_eq!(iteration_count, 3); - } -} - -#[test] -#[should_fail] -fn test_ptr_array_each_with_len_null_ptr() { - unsafe { - array_each_with_len(0 as *const *const libc::c_char, 1, |e| { - CString::new(e, false).as_str().unwrap(); - }); - } -} -#[test] -#[should_fail] -fn test_ptr_array_each_null_ptr() { - unsafe { - array_each(0 as *const *const libc::c_char, |e| { - CString::new(e, false).as_str().unwrap(); - }); - } -} - -#[test] fn test_set_memory() { let mut xs = [0u8, ..20]; let ptr = xs.as_mut_ptr(); diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index b023833f394..1cb72bd9eac 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::result::{collect, fold, fold_}; use core::iter::range; pub fn op1() -> Result<int, &'static str> { Ok(666) } @@ -69,48 +68,26 @@ pub fn test_impl_map_err() { } #[test] -#[allow(deprecated)] fn test_collect() { - let v: Result<Vec<int>, ()> = collect(range(0i, 0).map(|_| Ok::<int, ()>(0))); + let v: Result<Vec<int>, ()> = range(0i, 0).map(|_| Ok::<int, ()>(0)).collect(); assert!(v == Ok(vec![])); - let v: Result<Vec<int>, ()> = collect(range(0i, 3).map(|x| Ok::<int, ()>(x))); + let v: Result<Vec<int>, ()> = range(0i, 3).map(|x| Ok::<int, ()>(x)).collect(); assert!(v == Ok(vec![0, 1, 2])); - let v: Result<Vec<int>, int> = collect(range(0i, 3) - .map(|x| if x > 1 { Err(x) } else { Ok(x) })); + let v: Result<Vec<int>, int> = range(0i, 3).map(|x| { + if x > 1 { Err(x) } else { Ok(x) } + }).collect(); assert!(v == Err(2)); // test that it does not take more elements than it needs let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - let v: Result<Vec<()>, int> = collect(functions.iter_mut().map(|f| (*f)())); + let v: Result<Vec<()>, int> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == Err(1)); } #[test] -#[allow(deprecated)] // we know fold_ is deprecated -fn test_fold() { - assert_eq!(fold_(range(0i, 0) - .map(|_| Ok::<(), ()>(()))), - Ok(())); - assert_eq!(fold(range(0i, 3) - .map(|x| Ok::<int, ()>(x)), - 0, |a, b| a + b), - Ok(3)); - assert_eq!(fold_(range(0i, 3) - .map(|x| if x > 1 { Err(x) } else { Ok(()) })), - Err(2)); - - // test that it does not take more elements than it needs - let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - - assert_eq!(fold_(functions.iter_mut() - .map(|f| (*f)())), - Err(1)); -} - -#[test] pub fn test_fmt_default() { let ok: Result<int, &'static str> = Ok(100); let err: Result<int, &'static str> = Err("Err"); |
