Skip to content

Commit ed9d6e0

Browse files
committed
Move various stdlib tests to library/std/tests
1 parent ce609db commit ed9d6e0

9 files changed

+24
-33
lines changed

tests/ui/stdlib-unit-tests/builtin-clone.rs renamed to library/std/tests/builtin-clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ run-pass
21
// Test that `Clone` is correctly implemented for builtin types.
32
// Also test that cloning an array or a tuple is done right, i.e.
43
// each component is cloned.
@@ -18,7 +17,8 @@ impl Clone for S {
1817
}
1918
}
2019

21-
fn main() {
20+
#[test]
21+
fn builtin_clone() {
2222
test_clone(foo);
2323
test_clone([1; 56]);
2424
test_clone((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1));

tests/ui/stdlib-unit-tests/eq-multidispatch.rs renamed to library/std/tests/eq-multidispatch.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@ run-pass
2-
31
#[derive(PartialEq, Debug)]
42
struct Bar;
53
#[derive(Debug)]
@@ -17,7 +15,8 @@ impl PartialEq<Foo> for Fu { fn eq(&self, _: &Foo) -> bool { true } }
1715
impl PartialEq<Bar> for Foo { fn eq(&self, _: &Bar) -> bool { false } }
1816
impl PartialEq<Foo> for Bar { fn eq(&self, _: &Foo) -> bool { false } }
1917

20-
fn main() {
18+
#[test]
19+
fn eq_multidispatch() {
2120
assert!(Bar != Foo);
2221
assert!(Foo != Bar);
2322

tests/ui/stdlib-unit-tests/issue-21058.rs renamed to library/std/tests/issue-21058.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ run-pass
21
#![allow(dead_code)]
32

43
use std::fmt::Debug;
@@ -15,7 +14,8 @@ macro_rules! check {
1514
};
1615
}
1716

18-
fn main() {
17+
#[test]
18+
fn issue_21058() {
1919
// type_name should support unsized types
2020
check!([u8], "[u8]");
2121
check!(str, "str");
@@ -31,7 +31,7 @@ fn main() {
3131
<Foo as Debug>::fmt,
3232
"<issue_21058::Foo as core::fmt::Debug>::fmt"
3333
);
34-
check!(val: || {}, "issue_21058::main::{{closure}}");
34+
check!(val: || {}, "issue_21058::issue_21058::{{closure}}");
3535
bar::<i32>();
3636
}
3737

tests/ui/stdlib-unit-tests/istr.rs renamed to library/std/tests/istr.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//@ run-pass
2-
1+
#[test]
32
fn test_stack_assign() {
43
let s: String = "a".to_string();
54
println!("{}", s.clone());
@@ -9,8 +8,10 @@ fn test_stack_assign() {
98
assert!((s != u));
109
}
1110

11+
#[test]
1212
fn test_heap_lit() { "a big string".to_string(); }
1313

14+
#[test]
1415
fn test_heap_assign() {
1516
let s: String = "a big ol' string".to_string();
1617
let t: String = "a big ol' string".to_string();
@@ -19,11 +20,13 @@ fn test_heap_assign() {
1920
assert!((s != u));
2021
}
2122

23+
#[test]
2224
fn test_heap_log() {
2325
let s = "a big ol' string".to_string();
2426
println!("{}", s);
2527
}
2628

29+
#[test]
2730
fn test_append() {
2831
let mut s = String::new();
2932
s.push_str("a");
@@ -41,11 +44,3 @@ fn test_append() {
4144
s.push_str("&tea");
4245
assert_eq!(s, "coffee&tea");
4346
}
44-
45-
pub fn main() {
46-
test_stack_assign();
47-
test_heap_lit();
48-
test_heap_assign();
49-
test_heap_log();
50-
test_append();
51-
}

tests/ui/stdlib-unit-tests/log-knows-the-names-of-variants-in-std.rs renamed to library/std/tests/log-knows-the-names-of-variants-in-std.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//@ run-pass
2-
31
#![allow(non_camel_case_types)]
42
#![allow(dead_code)]
3+
54
#[derive(Clone, Debug)]
65
enum foo {
76
a(usize),
@@ -12,7 +11,8 @@ fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
1211
assert_eq!(exp, format!("{:?}", v));
1312
}
1413

15-
pub fn main() {
14+
#[test]
15+
fn log_knows_the_names_of_variants_in_std() {
1616
let mut x = Some(foo::a(22));
1717
let exp = "Some(a(22))".to_string();
1818
let act = format!("{:?}", x);

tests/ui/stdlib-unit-tests/minmax-stability-issue-23687.rs renamed to library/std/tests/minmax-stability-issue-23687.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@ run-pass
2-
31
use std::fmt::Debug;
42
use std::cmp::{self, Ordering};
53

@@ -21,7 +19,8 @@ impl Ord for Foo {
2119
}
2220
}
2321

24-
fn main() {
22+
#[test]
23+
fn minmax_stability() {
2524
let a = Foo { n: 4, name: "a" };
2625
let b = Foo { n: 4, name: "b" };
2726
let c = Foo { n: 8, name: "c" };

tests/ui/stdlib-unit-tests/seq-compare.rs renamed to library/std/tests/seq-compare.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
//@ run-pass
2-
3-
pub fn main() {
1+
#[test]
2+
fn seq_compare() {
43
assert!(("hello".to_string() < "hellr".to_string()));
54
assert!(("hello ".to_string() > "hello".to_string()));
65
assert!(("hello".to_string() != "there".to_string()));
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
//@ check-pass
2-
31
// This intends to use the unsizing coercion from array to slice, but it only
42
// works if we resolve `<&[u8]>::from` as the reflexive `From<T> for T`. In
53
// #113238, we found that gimli had added its own `From<EndianSlice> for &[u8]`
64
// that affected all `std/backtrace` users.
7-
fn main() {
5+
#[test]
6+
fn slice_from_array() {
87
let _ = <&[u8]>::from(&[]);
98
}

tests/ui/stdlib-unit-tests/volatile-fat-ptr.rs renamed to library/std/tests/volatile-fat-ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//@ run-pass
2-
31
#![allow(stable_features)]
42
#![feature(volatile)]
3+
54
use std::ptr::{read_volatile, write_volatile};
65

7-
fn main() {
6+
#[test]
7+
fn volatile_fat_ptr() {
88
let mut x: &'static str = "test";
99
unsafe {
1010
let a = read_volatile(&x);

0 commit comments

Comments
 (0)