diff options
| author | Ryan Lowe <rytheo@users.noreply.github.com> | 2024-04-28 15:37:14 -0400 |
|---|---|---|
| committer | Ryan Lowe <rytheo@users.noreply.github.com> | 2024-04-28 16:10:12 -0400 |
| commit | ed9d6e0c03b53aea602ea9b0a283b39491f73b91 (patch) | |
| tree | a00aaac61c8a2a3bd347dc16701555c2cf25f772 /tests | |
| parent | ce609db948f210807f61da999c57bd4ae5216254 (diff) | |
| download | rust-ed9d6e0c03b53aea602ea9b0a283b39491f73b91.tar.gz rust-ed9d6e0c03b53aea602ea9b0a283b39491f73b91.zip | |
Move various stdlib tests to library/std/tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/std/slice-from-array-issue-113238.rs | 9 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/builtin-clone.rs | 45 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/eq-multidispatch.rs | 30 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/issue-21058.rs | 64 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/istr.rs | 51 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs | 27 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs | 64 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/seq-compare.rs | 16 | ||||
| -rw-r--r-- | tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs | 15 |
9 files changed, 0 insertions, 321 deletions
diff --git a/tests/ui/std/slice-from-array-issue-113238.rs b/tests/ui/std/slice-from-array-issue-113238.rs deleted file mode 100644 index 44f2d7a9478..00000000000 --- a/tests/ui/std/slice-from-array-issue-113238.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass - -// This intends to use the unsizing coercion from array to slice, but it only -// works if we resolve `<&[u8]>::from` as the reflexive `From<T> for T`. In -// #113238, we found that gimli had added its own `From<EndianSlice> for &[u8]` -// that affected all `std/backtrace` users. -fn main() { - let _ = <&[u8]>::from(&[]); -} diff --git a/tests/ui/stdlib-unit-tests/builtin-clone.rs b/tests/ui/stdlib-unit-tests/builtin-clone.rs deleted file mode 100644 index 47c00ede0e9..00000000000 --- a/tests/ui/stdlib-unit-tests/builtin-clone.rs +++ /dev/null @@ -1,45 +0,0 @@ -//@ run-pass -// Test that `Clone` is correctly implemented for builtin types. -// Also test that cloning an array or a tuple is done right, i.e. -// each component is cloned. - -fn test_clone<T: Clone>(arg: T) { - let _ = arg.clone(); -} - -fn foo() { } - -#[derive(Debug, PartialEq, Eq)] -struct S(i32); - -impl Clone for S { - fn clone(&self) -> Self { - S(self.0 + 1) - } -} - -fn main() { - test_clone(foo); - test_clone([1; 56]); - test_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); - - let a = [S(0), S(1), S(2)]; - let b = [S(1), S(2), S(3)]; - assert_eq!(b, a.clone()); - - let a = ( - (S(1), S(0)), - ( - (S(0), S(0), S(1)), - S(0) - ) - ); - let b = ( - (S(2), S(1)), - ( - (S(1), S(1), S(2)), - S(1) - ) - ); - assert_eq!(b, a.clone()); -} diff --git a/tests/ui/stdlib-unit-tests/eq-multidispatch.rs b/tests/ui/stdlib-unit-tests/eq-multidispatch.rs deleted file mode 100644 index 4a991624e34..00000000000 --- a/tests/ui/stdlib-unit-tests/eq-multidispatch.rs +++ /dev/null @@ -1,30 +0,0 @@ -//@ run-pass - -#[derive(PartialEq, Debug)] -struct Bar; -#[derive(Debug)] -struct Baz; -#[derive(Debug)] -struct Foo; -#[derive(Debug)] -struct Fu; - -impl PartialEq for Baz { fn eq(&self, _: &Baz) -> bool { true } } - -impl PartialEq<Fu> for Foo { fn eq(&self, _: &Fu) -> bool { true } } -impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } } - -impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } } -impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } } - -fn main() { - assert!(Bar != Foo); - assert!(Foo != Bar); - - assert_eq!(Bar, Bar); - - assert_eq!(Baz, Baz); - - assert_eq!(Foo, Fu); - assert_eq!(Fu, Foo); -} diff --git a/tests/ui/stdlib-unit-tests/issue-21058.rs b/tests/ui/stdlib-unit-tests/issue-21058.rs deleted file mode 100644 index 0e04f1e21b8..00000000000 --- a/tests/ui/stdlib-unit-tests/issue-21058.rs +++ /dev/null @@ -1,64 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -use std::fmt::Debug; - -struct NT(str); -struct DST { a: u32, b: str } - -macro_rules! check { - (val: $ty_of:expr, $expected:expr) => { - assert_eq!(type_name_of_val($ty_of), $expected); - }; - ($ty:ty, $expected:expr) => { - assert_eq!(std::any::type_name::<$ty>(), $expected); - }; -} - -fn main() { - // type_name should support unsized types - check!([u8], "[u8]"); - check!(str, "str"); - check!(dyn Send, "dyn core::marker::Send"); - check!(NT, "issue_21058::NT"); - check!(DST, "issue_21058::DST"); - check!(&i32, "&i32"); - check!(&'static i32, "&i32"); - check!((i32, u32), "(i32, u32)"); - check!(val: foo(), "issue_21058::Foo"); - check!(val: Foo::new, "issue_21058::Foo::new"); - check!(val: - <Foo as Debug>::fmt, - "<issue_21058::Foo as core::fmt::Debug>::fmt" - ); - check!(val: || {}, "issue_21058::main::{{closure}}"); - bar::<i32>(); -} - -trait Trait { - type Assoc; -} - -impl Trait for i32 { - type Assoc = String; -} - -fn bar<T: Trait>() { - check!(T::Assoc, "alloc::string::String"); - check!(T, "i32"); -} - -fn type_name_of_val<T>(_: T) -> &'static str { - std::any::type_name::<T>() -} - -#[derive(Debug)] -struct Foo; - -impl Foo { - fn new() -> Self { Foo } -} - -fn foo() -> impl Debug { - Foo -} diff --git a/tests/ui/stdlib-unit-tests/istr.rs b/tests/ui/stdlib-unit-tests/istr.rs deleted file mode 100644 index f6298919425..00000000000 --- a/tests/ui/stdlib-unit-tests/istr.rs +++ /dev/null @@ -1,51 +0,0 @@ -//@ run-pass - -fn test_stack_assign() { - let s: String = "a".to_string(); - println!("{}", s.clone()); - let t: String = "a".to_string(); - assert_eq!(s, t); - let u: String = "b".to_string(); - assert!((s != u)); -} - -fn test_heap_lit() { "a big string".to_string(); } - -fn test_heap_assign() { - let s: String = "a big ol' string".to_string(); - let t: String = "a big ol' string".to_string(); - assert_eq!(s, t); - let u: String = "a bad ol' string".to_string(); - assert!((s != u)); -} - -fn test_heap_log() { - let s = "a big ol' string".to_string(); - println!("{}", s); -} - -fn test_append() { - let mut s = String::new(); - s.push_str("a"); - assert_eq!(s, "a"); - - let mut s = String::from("a"); - s.push_str("b"); - println!("{}", s.clone()); - assert_eq!(s, "ab"); - - let mut s = String::from("c"); - s.push_str("offee"); - assert_eq!(s, "coffee"); - - s.push_str("&tea"); - assert_eq!(s, "coffee&tea"); -} - -pub fn main() { - test_stack_assign(); - test_heap_lit(); - test_heap_assign(); - test_heap_log(); - test_append(); -} diff --git a/tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs b/tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs deleted file mode 100644 index 8f351b2b40b..00000000000 --- a/tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#[derive(Clone, Debug)] -enum foo { - a(usize), - b(String), -} - -fn check_log<T: std::fmt::Debug>(exp: String, v: T) { - assert_eq!(exp, format!("{:?}", v)); -} - -pub fn main() { - let mut x = Some(foo::a(22)); - let exp = "Some(a(22))".to_string(); - let act = format!("{:?}", x); - assert_eq!(act, exp); - check_log(exp, x); - - x = None; - let exp = "None".to_string(); - let act = format!("{:?}", x); - assert_eq!(act, exp); - check_log(exp, x); -} diff --git a/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs b/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs deleted file mode 100644 index bf42347df0b..00000000000 --- a/tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs +++ /dev/null @@ -1,64 +0,0 @@ -//@ run-pass - -use std::fmt::Debug; -use std::cmp::{self, Ordering}; - -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -struct Foo { - n: u8, - name: &'static str -} - -impl PartialOrd for Foo { - fn partial_cmp(&self, other: &Foo) -> Option<Ordering> { - Some(self.cmp(other)) - } -} - -impl Ord for Foo { - fn cmp(&self, other: &Foo) -> Ordering { - self.n.cmp(&other.n) - } -} - -fn main() { - let a = Foo { n: 4, name: "a" }; - let b = Foo { n: 4, name: "b" }; - let c = Foo { n: 8, name: "c" }; - let d = Foo { n: 8, name: "d" }; - let e = Foo { n: 22, name: "e" }; - let f = Foo { n: 22, name: "f" }; - - let data = [a, b, c, d, e, f]; - - // `min` should return the left when the values are equal - assert_eq!(data.iter().min(), Some(&a)); - assert_eq!(data.iter().min_by_key(|a| a.n), Some(&a)); - assert_eq!(cmp::min(a, b), a); - assert_eq!(cmp::min(b, a), b); - - // `max` should return the right when the values are equal - assert_eq!(data.iter().max(), Some(&f)); - assert_eq!(data.iter().max_by_key(|a| a.n), Some(&f)); - assert_eq!(cmp::max(e, f), f); - assert_eq!(cmp::max(f, e), e); - - let mut presorted = data.to_vec(); - presorted.sort(); - assert_stable(&presorted); - - let mut presorted = data.to_vec(); - presorted.sort_by(|a, b| a.cmp(b)); - assert_stable(&presorted); - - // Assert that sorted and min/max are the same - fn assert_stable<T: Ord + Debug>(presorted: &[T]) { - for slice in presorted.windows(2) { - let a = &slice[0]; - let b = &slice[1]; - - assert_eq!(a, cmp::min(a, b)); - assert_eq!(b, cmp::max(a, b)); - } - } -} diff --git a/tests/ui/stdlib-unit-tests/seq-compare.rs b/tests/ui/stdlib-unit-tests/seq-compare.rs deleted file mode 100644 index 1be0569e17c..00000000000 --- a/tests/ui/stdlib-unit-tests/seq-compare.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass - -pub fn main() { - assert!(("hello".to_string() < "hellr".to_string())); - assert!(("hello ".to_string() > "hello".to_string())); - assert!(("hello".to_string() != "there".to_string())); - assert!((vec![1, 2, 3, 4] > vec![1, 2, 3])); - assert!((vec![1, 2, 3] < vec![1, 2, 3, 4])); - assert!((vec![1, 2, 4, 4] > vec![1, 2, 3, 4])); - assert!((vec![1, 2, 3, 4] < vec![1, 2, 4, 4])); - assert!((vec![1, 2, 3] <= vec![1, 2, 3])); - assert!((vec![1, 2, 3] <= vec![1, 2, 3, 3])); - assert!((vec![1, 2, 3, 4] > vec![1, 2, 3])); - assert_eq!(vec![1, 2, 3], vec![1, 2, 3]); - assert!((vec![1, 2, 3] != vec![1, 1, 3])); -} diff --git a/tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs b/tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs deleted file mode 100644 index ef227a9134d..00000000000 --- a/tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(volatile)] -use std::ptr::{read_volatile, write_volatile}; - -fn main() { - let mut x: &'static str = "test"; - unsafe { - let a = read_volatile(&x); - assert_eq!(a, "test"); - write_volatile(&mut x, "foo"); - assert_eq!(x, "foo"); - } -} |
