Skip to content

Commit 5818f13

Browse files
committed
Adding tests for closed issues
Closes #5521 Closes #8827 Closes #9396 Closes #10714
1 parent 62caad2 commit 5818f13

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed

src/test/auxiliary/issue-5521.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 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+
#[feature(managed_boxes)];
12+
13+
use std::hashmap::HashMap;
14+
15+
pub type map = @HashMap<uint, uint>;

src/test/run-pass/issue-10714.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2014 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+
enum v {}
12+
pub fn main() {
13+
let y: v = unsafe { ::std::unstable::intrinsics::uninit() };
14+
}

src/test/run-pass/issue-5521.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 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+
// aux-build:issue-5521.rs
12+
// xfail-fast
13+
14+
#[feature(managed_boxes)];
15+
16+
extern mod foo = "issue-5521";
17+
18+
fn foo(a: foo::map) {
19+
if false {
20+
fail!();
21+
} else {
22+
let _b = a.get(&2);
23+
}
24+
}
25+
26+
fn main() {}

src/test/run-pass/issue-8827.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2014 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+
fn periodical(n: int) -> Port<bool> {
12+
let (port, chan) = Chan::new();
13+
spawn(proc() {
14+
debug!("periodical {} - begin", n);
15+
loop {
16+
for _ in range(1, n) {
17+
debug!("periodical {} - sending...", n);
18+
if !chan.try_send(false) {
19+
break
20+
}
21+
debug!("periodical {} - sent", n);
22+
}
23+
if !chan.try_send(true) {
24+
break
25+
}
26+
}
27+
});
28+
return port;
29+
}
30+
31+
fn integers() -> Port<int> {
32+
let (port, chan) = Chan::new();
33+
spawn(proc() {
34+
debug!("integers - begin");
35+
let mut i = 1;
36+
loop {
37+
if !chan.try_send(i) {
38+
break
39+
}
40+
i = i + 1;
41+
}
42+
});
43+
return port;
44+
}
45+
46+
pub fn main() {
47+
let ints = integers();
48+
let threes = periodical(3);
49+
let fives = periodical(5);
50+
for _ in range(1, 100) {
51+
match (ints.recv(), threes.recv(), fives.recv()) {
52+
(_, true, true) => println!("FizzBuzz"),
53+
(_, true, false) => println!("Fizz"),
54+
(_, false, true) => println!("Buzz"),
55+
(i, false, false) => println!("{}", i)
56+
}
57+
}
58+
}

src/test/run-pass/issue-9396.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2014 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+
use std::comm;
12+
use std::io::timer::Timer;
13+
14+
pub fn main() {
15+
let (port, chan) = Chan::new();
16+
spawn(proc (){
17+
let mut timer = Timer::new().unwrap();
18+
timer.sleep(10);
19+
chan.send(());
20+
});
21+
loop {
22+
match port.try_recv() {
23+
comm::Data(()) => break,
24+
comm::Empty => {}
25+
comm::Disconnected => unreachable!()
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)