about summary refs log tree commit diff
path: root/src/libcoretest
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcoretest')
-rw-r--r--src/libcoretest/cell.rs13
-rw-r--r--src/libcoretest/finally.rs62
-rw-r--r--src/libcoretest/iter.rs14
-rw-r--r--src/libcoretest/lib.rs1
-rw-r--r--src/libcoretest/str.rs18
5 files changed, 21 insertions, 87 deletions
diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs
index fff3cc14ead..85dd1039003 100644
--- a/src/libcoretest/cell.rs
+++ b/src/libcoretest/cell.rs
@@ -59,7 +59,6 @@ fn double_imm_borrow() {
 fn no_mut_then_imm_borrow() {
     let x = RefCell::new(0);
     let _b1 = x.borrow_mut();
-    assert!(x.try_borrow().is_none());
     assert_eq!(x.borrow_state(), BorrowState::Writing);
 }
 
@@ -67,7 +66,6 @@ fn no_mut_then_imm_borrow() {
 fn no_imm_then_borrow_mut() {
     let x = RefCell::new(0);
     let _b1 = x.borrow();
-    assert!(x.try_borrow_mut().is_none());
     assert_eq!(x.borrow_state(), BorrowState::Reading);
 }
 
@@ -76,7 +74,6 @@ fn no_double_borrow_mut() {
     let x = RefCell::new(0);
     assert_eq!(x.borrow_state(), BorrowState::Unused);
     let _b1 = x.borrow_mut();
-    assert!(x.try_borrow_mut().is_none());
     assert_eq!(x.borrow_state(), BorrowState::Writing);
 }
 
@@ -105,7 +102,7 @@ fn double_borrow_single_release_no_borrow_mut() {
     {
         let _b2 = x.borrow();
     }
-    assert!(x.try_borrow_mut().is_none());
+    assert_eq!(x.borrow_state(), BorrowState::Reading);
 }
 
 #[test]
@@ -122,14 +119,14 @@ fn clone_ref_updates_flag() {
     let x = RefCell::new(0);
     {
         let b1 = x.borrow();
-        assert!(x.try_borrow_mut().is_none());
+        assert_eq!(x.borrow_state(), BorrowState::Reading);
         {
             let _b2 = clone_ref(&b1);
-            assert!(x.try_borrow_mut().is_none());
+            assert_eq!(x.borrow_state(), BorrowState::Reading);
         }
-        assert!(x.try_borrow_mut().is_none());
+        assert_eq!(x.borrow_state(), BorrowState::Reading);
     }
-    assert!(x.try_borrow_mut().is_some());
+    assert_eq!(x.borrow_state(), BorrowState::Unused);
 }
 
 #[test]
diff --git a/src/libcoretest/finally.rs b/src/libcoretest/finally.rs
deleted file mode 100644
index 2a48395271d..00000000000
--- a/src/libcoretest/finally.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <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::finally::{try_finally, Finally};
-use std::thread;
-
-#[test]
-fn test_success() {
-    let mut i = 0;
-    try_finally(
-        &mut i, (),
-        |i, ()| {
-            *i = 10;
-        },
-        |i| {
-            assert!(!thread::panicking());
-            assert_eq!(*i, 10);
-            *i = 20;
-        });
-    assert_eq!(i, 20);
-}
-
-#[test]
-#[should_panic]
-fn test_fail() {
-    let mut i = 0;
-    try_finally(
-        &mut i, (),
-        |i, ()| {
-            *i = 10;
-            panic!();
-        },
-        |i| {
-            assert!(thread::panicking());
-            assert_eq!(*i, 10);
-        })
-}
-
-#[test]
-fn test_retval() {
-    let mut closure = || 10;
-    // FIXME(#16640) `: i32` annotation shouldn't be necessary
-    let i: i32 = closure.finally(|| { });
-    assert_eq!(i, 10);
-}
-
-#[test]
-fn test_compact() {
-    fn do_some_fallible_work() {}
-    fn but_always_run_this_function() { }
-    let mut f = do_some_fallible_work;
-    f.finally(but_always_run_this_function);
-}
diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs
index 15938a5dcb4..af80d347f02 100644
--- a/src/libcoretest/iter.rs
+++ b/src/libcoretest/iter.rs
@@ -72,7 +72,7 @@ fn test_multi_iter() {
 
 #[test]
 fn test_counter_from_iter() {
-    let it = count(0, 5).take(10);
+    let it = (0..).step_by(5).take(10);
     let xs: Vec<isize> = FromIterator::from_iter(it);
     assert_eq!(xs, [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
 }
@@ -90,7 +90,7 @@ fn test_iterator_chain() {
     }
     assert_eq!(i, expected.len());
 
-    let ys = count(30, 10).take(4);
+    let ys = (30..).step_by(10).take(4);
     let it = xs.iter().cloned().chain(ys);
     let mut i = 0;
     for x in it {
@@ -102,7 +102,7 @@ fn test_iterator_chain() {
 
 #[test]
 fn test_filter_map() {
-    let it = count(0, 1).take(10)
+    let it = (0..).step_by(1).take(10)
         .filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
     assert_eq!(it.collect::<Vec<usize>>(), [0*0, 2*2, 4*4, 6*6, 8*8]);
 }
@@ -244,7 +244,7 @@ fn test_iterator_scan() {
 fn test_iterator_flat_map() {
     let xs = [0, 3, 6];
     let ys = [0, 1, 2, 3, 4, 5, 6, 7, 8];
-    let it = xs.iter().flat_map(|&x| count(x, 1).take(3));
+    let it = xs.iter().flat_map(|&x| (x..).step_by(1).take(3));
     let mut i = 0;
     for x in it {
         assert_eq!(x, ys[i]);
@@ -291,13 +291,13 @@ fn test_unfoldr() {
 #[test]
 fn test_cycle() {
     let cycle_len = 3;
-    let it = count(0, 1).take(cycle_len).cycle();
+    let it = (0..).step_by(1).take(cycle_len).cycle();
     assert_eq!(it.size_hint(), (usize::MAX, None));
     for (i, x) in it.take(100).enumerate() {
         assert_eq!(i % cycle_len, x);
     }
 
-    let mut it = count(0, 1).take(0).cycle();
+    let mut it = (0..).step_by(1).take(0).cycle();
     assert_eq!(it.size_hint(), (0, Some(0)));
     assert_eq!(it.next(), None);
 }
@@ -360,7 +360,7 @@ fn test_iterator_min() {
 
 #[test]
 fn test_iterator_size_hint() {
-    let c = count(0, 1);
+    let c = (0..).step_by(1);
     let v: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
     let v2 = &[10, 11, 12];
     let vi = v.iter();
diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs
index 9cc3063dee6..7ae0dcbb5f9 100644
--- a/src/libcoretest/lib.rs
+++ b/src/libcoretest/lib.rs
@@ -39,7 +39,6 @@ mod atomic;
 mod cell;
 mod char;
 mod cmp;
-mod finally;
 mod fmt;
 mod hash;
 mod iter;
diff --git a/src/libcoretest/str.rs b/src/libcoretest/str.rs
index 38cab4f0e09..c935b554574 100644
--- a/src/libcoretest/str.rs
+++ b/src/libcoretest/str.rs
@@ -163,9 +163,9 @@ fn starts_short_long() {
 
 #[test]
 fn contains_weird_cases() {
-    assert!("* \t".contains_char(' '));
-    assert!(!"* \t".contains_char('?'));
-    assert!(!"* \t".contains_char('\u{1F4A9}'));
+    assert!("* \t".contains(' '));
+    assert!(!"* \t".contains('?'));
+    assert!(!"* \t".contains('\u{1F4A9}'));
 }
 
 #[test]
@@ -347,11 +347,11 @@ malesuada sollicitudin quam eu fermentum!");
     make_test!(chars_count, s, s.chars().count());
 
     make_test!(contains_bang_str, s, s.contains("!"));
-    make_test!(contains_bang_char, s, s.contains_char('!'));
+    make_test!(contains_bang_char, s, s.contains('!'));
 
     make_test!(match_indices_a_str, s, s.match_indices("a").count());
 
-    make_test!(split_str_a_str, s, s.split_str("a").count());
+    make_test!(split_a_str, s, s.split("a").count());
 
     make_test!(trim_ascii_char, s, {
         use std::ascii::AsciiExt;
@@ -368,11 +368,11 @@ malesuada sollicitudin quam eu fermentum!");
 
     make_test!(find_underscore_char, s, s.find('_'));
     make_test!(rfind_underscore_char, s, s.rfind('_'));
-    make_test!(find_underscore_str, s, s.find_str("_"));
+    make_test!(find_underscore_str, s, s.find("_"));
 
     make_test!(find_zzz_char, s, s.find('\u{1F4A4}'));
     make_test!(rfind_zzz_char, s, s.rfind('\u{1F4A4}'));
-    make_test!(find_zzz_str, s, s.find_str("\u{1F4A4}"));
+    make_test!(find_zzz_str, s, s.find("\u{1F4A4}"));
 
     make_test!(split_space_char, s, s.split(' ').count());
     make_test!(split_terminator_space_char, s, s.split_terminator(' ').count());
@@ -380,6 +380,6 @@ malesuada sollicitudin quam eu fermentum!");
     make_test!(splitn_space_char, s, s.splitn(10, ' ').count());
     make_test!(rsplitn_space_char, s, s.rsplitn(10, ' ').count());
 
-    make_test!(split_str_space_str, s, s.split_str(" ").count());
-    make_test!(split_str_ad_str, s, s.split_str("ad").count());
+    make_test!(split_space_str, s, s.split(" ").count());
+    make_test!(split_ad_str, s, s.split("ad").count());
 }