Skip to content

Commit 12099ce

Browse files
committed
Tests for fixed issues.
Closes #3794. Closes #4025. Closes #5688. Closes #5708. Closes #7012. Closes #7327.
1 parent 364beaa commit 12099ce

File tree

6 files changed

+171
-1
lines changed

6 files changed

+171
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2012 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+
// issue 7327
12+
13+
// xfail-fast #7103
14+
extern mod extra;
15+
use extra::arc::*;
16+
17+
struct A { y: Arc<int>, x: Arc<int> }
18+
19+
impl Drop for A {
20+
fn drop(&self) { println(fmt!("x=%?", self.x.get())); }
21+
}
22+
fn main() {
23+
let a = A { y: Arc::new(1), x: Arc::new(2) };
24+
let _b = A { y: Arc::new(3), ..a };
25+
let _c = a; //~ ERROR use of moved value
26+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
1211
trait T {
1312
fn print(&self);
1413
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
/*
12+
# if b { x } else { y } requires identical types for x and y
13+
*/
14+
15+
fn print1(b: bool, s1: &str, s2: &str) {
16+
println(if b { s1 } else { s2 });
17+
}
18+
fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
19+
println(if b { s1 } else { s2 });
20+
}
21+
fn print3(b: bool, s1: &str, s2: &str) {
22+
let mut s: &str;
23+
if b { s = s1; } else { s = s2; }
24+
println(s);
25+
}
26+
fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
27+
let mut s: &str;
28+
if b { s = s1; } else { s = s2; }
29+
println(s);
30+
}
31+
32+
pub fn main() {}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
/*
12+
# Corrupted initialization in the static struct
13+
14+
...should print &[1, 2, 3] but instead prints something like
15+
&[4492532864, 24]. It is pretty evident that the compiler messed up
16+
with the representation of [int, ..n] and [int] somehow, or at least
17+
failed to typecheck correctly.
18+
*/
19+
20+
struct X { vec: &'static [int] }
21+
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
22+
fn main() {
23+
for &v in V.iter() {
24+
println(fmt!("%?", v.vec));
25+
}
26+
}

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
/*
12+
# ICE when returning struct with borrowed pointer to trait
13+
14+
A function which takes a borrowed pointer to a trait and returns a
15+
struct with that borrowed pointer results in an ICE.
16+
17+
This does not occur with concrete types, only with borrowed pointers
18+
to traits.
19+
*/
20+
21+
// original
22+
trait Inner {
23+
fn print(&self);
24+
}
25+
26+
impl Inner for int {
27+
fn print(&self) { print(fmt!("Inner: %d\n", *self)); }
28+
}
29+
30+
struct Outer<'self> {
31+
inner: &'self Inner
32+
}
33+
34+
impl<'self> Outer<'self> {
35+
fn new<'r>(inner: &'r Inner) -> Outer<'r> {
36+
Outer {
37+
inner: inner
38+
}
39+
}
40+
}
41+
42+
fn main() {
43+
let inner = 5;
44+
let outer = Outer::new(&inner as &Inner);
45+
outer.inner.print();
46+
}
47+
48+
49+
// minimal
50+
trait MyTrait<T> { }
51+
52+
pub struct MyContainer<'self, T> {
53+
foos: ~[&'self MyTrait<T>],
54+
}
55+
56+
impl<'self, T> MyContainer<'self, T> {
57+
pub fn add (&mut self, foo: &'self MyTrait<T>) {
58+
self.foos.push(foo);
59+
}
60+
}

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
/*
12+
# Comparison of static arrays
13+
14+
The expected behaviour would be that test==test1, therefore 'true'
15+
would be printed, however the below prints false.
16+
*/
17+
18+
struct signature<'self> { pattern : &'self [u32] }
19+
20+
static test1: signature<'static> = signature {
21+
pattern: &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32]
22+
};
23+
24+
fn main() {
25+
let test = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32];
26+
println(fmt!("%b",test==test1.pattern));
27+
}

0 commit comments

Comments
 (0)