Tests for fixed issues.
Closes #3794. Closes #4025. Closes #5688. Closes #5708. Closes #7012. Closes #7327.
This commit is contained in:
parent
364beaa776
commit
12099ce94c
@ -0,0 +1,26 @@
|
||||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// issue 7327
|
||||
|
||||
// xfail-fast #7103
|
||||
extern mod extra;
|
||||
use extra::arc::*;
|
||||
|
||||
struct A { y: Arc<int>, x: Arc<int> }
|
||||
|
||||
impl Drop for A {
|
||||
fn drop(&self) { println(fmt!("x=%?", self.x.get())); }
|
||||
}
|
||||
fn main() {
|
||||
let a = A { y: Arc::new(1), x: Arc::new(2) };
|
||||
let _b = A { y: Arc::new(3), ..a };
|
||||
let _c = a; //~ ERROR use of moved value
|
||||
}
|
@ -8,7 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
trait T {
|
||||
fn print(&self);
|
||||
}
|
||||
|
32
src/test/run-pass/issue-4025.rs
Normal file
32
src/test/run-pass/issue-4025.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
/*
|
||||
# if b { x } else { y } requires identical types for x and y
|
||||
*/
|
||||
|
||||
fn print1(b: bool, s1: &str, s2: &str) {
|
||||
println(if b { s1 } else { s2 });
|
||||
}
|
||||
fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
|
||||
println(if b { s1 } else { s2 });
|
||||
}
|
||||
fn print3(b: bool, s1: &str, s2: &str) {
|
||||
let mut s: &str;
|
||||
if b { s = s1; } else { s = s2; }
|
||||
println(s);
|
||||
}
|
||||
fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
|
||||
let mut s: &str;
|
||||
if b { s = s1; } else { s = s2; }
|
||||
println(s);
|
||||
}
|
||||
|
||||
pub fn main() {}
|
26
src/test/run-pass/issue-5688.rs
Normal file
26
src/test/run-pass/issue-5688.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
/*
|
||||
# Corrupted initialization in the static struct
|
||||
|
||||
...should print &[1, 2, 3] but instead prints something like
|
||||
&[4492532864, 24]. It is pretty evident that the compiler messed up
|
||||
with the representation of [int, ..n] and [int] somehow, or at least
|
||||
failed to typecheck correctly.
|
||||
*/
|
||||
|
||||
struct X { vec: &'static [int] }
|
||||
static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
|
||||
fn main() {
|
||||
for &v in V.iter() {
|
||||
println(fmt!("%?", v.vec));
|
||||
}
|
||||
}
|
60
src/test/run-pass/issue-5708.rs
Normal file
60
src/test/run-pass/issue-5708.rs
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
/*
|
||||
# ICE when returning struct with borrowed pointer to trait
|
||||
|
||||
A function which takes a borrowed pointer to a trait and returns a
|
||||
struct with that borrowed pointer results in an ICE.
|
||||
|
||||
This does not occur with concrete types, only with borrowed pointers
|
||||
to traits.
|
||||
*/
|
||||
|
||||
// original
|
||||
trait Inner {
|
||||
fn print(&self);
|
||||
}
|
||||
|
||||
impl Inner for int {
|
||||
fn print(&self) { print(fmt!("Inner: %d\n", *self)); }
|
||||
}
|
||||
|
||||
struct Outer<'self> {
|
||||
inner: &'self Inner
|
||||
}
|
||||
|
||||
impl<'self> Outer<'self> {
|
||||
fn new<'r>(inner: &'r Inner) -> Outer<'r> {
|
||||
Outer {
|
||||
inner: inner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let inner = 5;
|
||||
let outer = Outer::new(&inner as &Inner);
|
||||
outer.inner.print();
|
||||
}
|
||||
|
||||
|
||||
// minimal
|
||||
trait MyTrait<T> { }
|
||||
|
||||
pub struct MyContainer<'self, T> {
|
||||
foos: ~[&'self MyTrait<T>],
|
||||
}
|
||||
|
||||
impl<'self, T> MyContainer<'self, T> {
|
||||
pub fn add (&mut self, foo: &'self MyTrait<T>) {
|
||||
self.foos.push(foo);
|
||||
}
|
||||
}
|
27
src/test/run-pass/issue-7012.rs
Normal file
27
src/test/run-pass/issue-7012.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
/*
|
||||
# Comparison of static arrays
|
||||
|
||||
The expected behaviour would be that test==test1, therefore 'true'
|
||||
would be printed, however the below prints false.
|
||||
*/
|
||||
|
||||
struct signature<'self> { pattern : &'self [u32] }
|
||||
|
||||
static test1: signature<'static> = signature {
|
||||
pattern: &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32]
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let test = &[0x243f6a88u32,0x85a308d3u32,0x13198a2eu32,0x03707344u32,0xa4093822u32,0x299f31d0u32];
|
||||
println(fmt!("%b",test==test1.pattern));
|
||||
}
|
Loading…
Reference in New Issue
Block a user