Skip to content

Commit deb80c7

Browse files
committed
---
yaml --- r: 59355 b: refs/heads/snap-stage3 c: 4a43c1b h: refs/heads/master i: 59353: f1952aa 59351: 9e90866 v: v3
1 parent c9aff14 commit deb80c7

File tree

5 files changed

+148
-1
lines changed

5 files changed

+148
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 5e1d6c2c8011f466d2a524231e5386df0b5ed841
4+
refs/heads/snap-stage3: 4a43c1babbdf453fc4af25cf06aae7c96213d918
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deriving(Rand)]
12+
struct A;
13+
14+
#[deriving(Rand)]
15+
struct B(int, int);
16+
17+
#[deriving(Rand)]
18+
struct C {
19+
x: f64,
20+
y: (u8, u8)
21+
}
22+
23+
#[deriving(Rand)]
24+
enum D {
25+
D0,
26+
D1(uint),
27+
D2 { x: (), y: () }
28+
}
29+
30+
fn main() {
31+
// check there's no segfaults
32+
for 20.times {
33+
rand::random::<A>();
34+
rand::random::<B>();
35+
rand::random::<C>();
36+
rand::random::<D>();
37+
}
38+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// xfail-test FIXME #6257
2+
3+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
4+
// file at the top-level directory of this distribution and at
5+
// http://rust-lang.org/COPYRIGHT.
6+
//
7+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
// option. This file may not be copied, modified, or distributed
11+
// except according to those terms.
12+
13+
use core::cmp::{Less,Equal,Greater};
14+
15+
#[deriving(TotalEq,TotalOrd)]
16+
struct A<'self> {
17+
x: &'self int
18+
}
19+
20+
fn main() {
21+
let a = A { x: &1 }, b = A { x: &2 };
22+
23+
assert!(a.equals(&a));
24+
assert!(b.equals(&b));
25+
26+
27+
assert_eq!(a.cmp(&a), Equal);
28+
assert_eq!(b.cmp(&b), Equal);
29+
30+
assert_eq!(a.cmp(&b), Less);
31+
assert_eq!(b.cmp(&a), Greater);
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deriving(Eq,Ord)]
12+
struct A<'self> {
13+
x: &'self int
14+
}
15+
16+
fn main() {
17+
let a = A { x: &1 }, b = A { x: &2 };
18+
19+
assert_eq!(a, a);
20+
assert_eq!(b, b);
21+
22+
23+
assert!(a < b);
24+
assert!(b > a);
25+
26+
assert!(a <= b);
27+
assert!(a <= a);
28+
assert!(b <= b);
29+
30+
assert!(b >= a);
31+
assert!(b >= b);
32+
assert!(a >= a);
33+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deriving(Rand,ToStr)]
12+
struct A;
13+
14+
#[deriving(Rand,ToStr)]
15+
struct B(int, int);
16+
17+
#[deriving(Rand,ToStr)]
18+
struct C {
19+
x: f64,
20+
y: (u8, u8)
21+
}
22+
23+
#[deriving(Rand,ToStr)]
24+
enum D {
25+
D0,
26+
D1(uint),
27+
D2 { x: (), y: () }
28+
}
29+
30+
fn main() {
31+
macro_rules! t(
32+
($ty:ty) => {{
33+
let x =rand::random::<$ty>();
34+
assert_eq!(x.to_str(), fmt!("%?", x));
35+
}}
36+
);
37+
38+
for 20.times {
39+
t!(A);
40+
t!(B);
41+
t!(C);
42+
t!(D);
43+
}
44+
}

0 commit comments

Comments
 (0)