auto merge of #8485 : alexcrichton/rust/add-tests, r=catamorphism
Closes #3907 Closes #5493 Closes #4464 Closes #4759 Closes #5666 Closes #5884 Closes #5926 Closes #6318 Closes #6557 Closes #6898 Closes #6919 Closes #7222
This commit is contained in:
commit
c4656cfd04
@ -93,7 +93,7 @@ string.
|
||||
Because formatting is done via traits, there is no requirement that the
|
||||
`d` format actually takes an `int`, but rather it simply requires a type which
|
||||
ascribes to the `Signed` formatting trait. There are various parameters which do
|
||||
require a particular type, however. Namely if the sytnax `{:.*s}` is used, then
|
||||
require a particular type, however. Namely if the syntax `{:.*s}` is used, then
|
||||
the number of characters to print from the string precedes the actual string and
|
||||
must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is
|
||||
illegal to reference an argument as such. For example, this is another invalid
|
||||
|
23
src/test/auxiliary/iss.rs
Normal file
23
src/test/auxiliary/iss.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
#[link(name="iss6919_3", vers="0.1")];
|
||||
|
||||
// part of issue-6919.rs
|
||||
|
||||
struct C<'self> {
|
||||
k: &'self fn(),
|
||||
}
|
||||
|
||||
fn no_op() { }
|
||||
pub static D : C<'static> = C {
|
||||
k: no_op
|
||||
};
|
||||
|
14
src/test/auxiliary/issue_3907.rs
Normal file
14
src/test/auxiliary/issue_3907.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// 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.
|
||||
|
||||
pub trait Foo {
|
||||
fn bar();
|
||||
}
|
||||
|
25
src/test/auxiliary/issue_8401.rs
Normal file
25
src/test/auxiliary/issue_8401.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
// for this issue, this code must be built in a library
|
||||
|
||||
use std::cast;
|
||||
|
||||
trait A {}
|
||||
struct B;
|
||||
impl A for B {}
|
||||
|
||||
fn bar<T>(_: &mut A, _: &T) {}
|
||||
|
||||
fn foo<T>(t: &T) {
|
||||
let b = B;
|
||||
bar(unsafe { cast::transmute(&b as &A) }, t)
|
||||
}
|
||||
|
30
src/test/compile-fail/issue-3907.rs
Normal file
30
src/test/compile-fail/issue-3907.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// 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.
|
||||
|
||||
// aux-build:issue_3907.rs
|
||||
extern mod issue_3907;
|
||||
|
||||
type Foo = issue_3907::Foo; //~ ERROR: reference to trait
|
||||
|
||||
struct S {
|
||||
name: int
|
||||
}
|
||||
|
||||
impl Foo for S { //~ ERROR: Foo is not a trait
|
||||
fn bar() { }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = S {
|
||||
name: 0
|
||||
};
|
||||
s.bar();
|
||||
}
|
||||
|
29
src/test/compile-fail/issue-5439.rs
Normal file
29
src/test/compile-fail/issue-5439.rs
Normal file
@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
struct Foo {
|
||||
foo: int,
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
bar: int,
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
fn make_foo (&self, i: int) -> ~Foo {
|
||||
return ~Foo { nonexistent: self, foo: i }; //~ ERROR: no field named
|
||||
}
|
||||
}
|
||||
|
||||
fn main () {
|
||||
let bar = Bar { bar: 1 };
|
||||
let foo = bar.make_foo(2);
|
||||
println(fmt!("%d", foo.foo));
|
||||
}
|
13
src/test/run-pass/issue-4464.rs
Normal file
13
src/test/run-pass/issue-4464.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.
|
||||
|
||||
fn broken<'r>(v: &'r [u8], i: uint, j: uint) -> &'r [u8] { v.slice(i, j) }
|
||||
|
||||
pub fn main() {}
|
13
src/test/run-pass/issue-4759-1.rs
Normal file
13
src/test/run-pass/issue-4759-1.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.
|
||||
|
||||
trait U { fn f(self); }
|
||||
impl U for int { fn f(self) {} }
|
||||
pub fn main() { 4.f(); }
|
25
src/test/run-pass/issue-4759.rs
Normal file
25
src/test/run-pass/issue-4759.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
struct T { a: ~int }
|
||||
|
||||
trait U {
|
||||
fn f(self);
|
||||
}
|
||||
|
||||
impl U for ~int {
|
||||
fn f(self) { }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let T { a: a } = T { a: ~0 };
|
||||
a.f();
|
||||
}
|
||||
|
35
src/test/run-pass/issue-5666.rs
Normal file
35
src/test/run-pass/issue-5666.rs
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
struct Dog {
|
||||
name : ~str
|
||||
}
|
||||
|
||||
trait Barks {
|
||||
fn bark(&self) -> ~str;
|
||||
}
|
||||
|
||||
impl Barks for Dog {
|
||||
fn bark(&self) -> ~str {
|
||||
return fmt!("woof! (I'm %s)", self.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn main() {
|
||||
let snoopy = ~Dog{name: ~"snoopy"};
|
||||
let bubbles = ~Dog{name: ~"bubbles"};
|
||||
let barker = [snoopy as ~Barks, bubbles as ~Barks];
|
||||
|
||||
for pup in barker.iter() {
|
||||
println(fmt!("%s", pup.bark()));
|
||||
}
|
||||
}
|
||||
|
24
src/test/run-pass/issue-5884.rs
Normal file
24
src/test/run-pass/issue-5884.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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.
|
||||
|
||||
pub struct Foo {
|
||||
a: int,
|
||||
}
|
||||
|
||||
struct Bar<'self> {
|
||||
a: ~Option<int>,
|
||||
b: &'self Foo,
|
||||
}
|
||||
|
||||
fn check(a: @Foo) {
|
||||
let mut _ic = Bar{ b: a, a: ~None };
|
||||
}
|
||||
|
||||
pub fn main(){}
|
17
src/test/run-pass/issue-5926.rs
Normal file
17
src/test/run-pass/issue-5926.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.
|
||||
|
||||
pub fn main() {
|
||||
let mut your_favorite_numbers = @[1,2,3];
|
||||
let mut my_favorite_numbers = @[4,5,6];
|
||||
let f = your_favorite_numbers + my_favorite_numbers;
|
||||
println(fmt!("The third favorite number is %?.", f))
|
||||
}
|
||||
|
26
src/test/run-pass/issue-6318.rs
Normal file
26
src/test/run-pass/issue-6318.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.
|
||||
|
||||
pub enum Thing {
|
||||
A(~Foo)
|
||||
}
|
||||
|
||||
pub trait Foo {}
|
||||
|
||||
pub struct Struct;
|
||||
|
||||
impl Foo for Struct {}
|
||||
|
||||
pub fn main() {
|
||||
match A(~Struct as ~Foo) {
|
||||
A(a) => 0,
|
||||
};
|
||||
}
|
||||
|
13
src/test/run-pass/issue-6557.rs
Normal file
13
src/test/run-pass/issue-6557.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.
|
||||
|
||||
fn foo(~(x, y): ~(int, int)) {}
|
||||
|
||||
pub fn main() {}
|
40
src/test/run-pass/issue-6898.rs
Normal file
40
src/test/run-pass/issue-6898.rs
Normal file
@ -0,0 +1,40 @@
|
||||
// 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.
|
||||
|
||||
use std::unstable::intrinsics;
|
||||
|
||||
/// Returns the size of a type
|
||||
pub fn size_of<T>() -> uint {
|
||||
TypeInfo::size_of::<T>()
|
||||
}
|
||||
|
||||
/// Returns the size of the type that `val` points to
|
||||
pub fn size_of_val<T>(val: &T) -> uint {
|
||||
val.size_of_val()
|
||||
}
|
||||
|
||||
pub trait TypeInfo {
|
||||
fn size_of() -> uint;
|
||||
fn size_of_val(&self) -> uint;
|
||||
}
|
||||
|
||||
impl<T> TypeInfo for T {
|
||||
/// The size of the type in bytes.
|
||||
fn size_of() -> uint {
|
||||
unsafe { intrinsics::size_of::<T>() }
|
||||
}
|
||||
|
||||
/// Returns the size of the type of `self` in bytes.
|
||||
fn size_of_val(&self) -> uint {
|
||||
TypeInfo::size_of::<T>()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
19
src/test/run-pass/issue-6919.rs
Normal file
19
src/test/run-pass/issue-6919.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
// aux-build:iss.rs
|
||||
// xfail-fast
|
||||
|
||||
extern mod iss ( name = "iss6919_3" );
|
||||
|
||||
pub fn main() {
|
||||
iss::D.k;
|
||||
}
|
||||
|
19
src/test/run-pass/issue-7222.rs
Normal file
19
src/test/run-pass/issue-7222.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
pub fn main() {
|
||||
static FOO: float = 10.0;
|
||||
|
||||
match 0.0 {
|
||||
0.0 .. FOO => (),
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
21
src/test/run-pass/issue-8248.rs
Normal file
21
src/test/run-pass/issue-8248.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
trait A {}
|
||||
struct B;
|
||||
impl A for B {}
|
||||
|
||||
fn foo(_: &mut A) {}
|
||||
|
||||
fn main() {
|
||||
let mut b = B;
|
||||
foo(&mut b as &mut A);
|
||||
}
|
||||
|
25
src/test/run-pass/issue-8249.rs
Normal file
25
src/test/run-pass/issue-8249.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
trait A {}
|
||||
struct B;
|
||||
impl A for B {}
|
||||
|
||||
struct C<'self> {
|
||||
foo: &'self mut A,
|
||||
}
|
||||
|
||||
fn foo(a: &mut A) {
|
||||
C{ foo: a };
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
18
src/test/run-pass/issue-8398.rs
Normal file
18
src/test/run-pass/issue-8398.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.
|
||||
|
||||
use std::rt::io;
|
||||
|
||||
fn foo(a: &mut io::Writer) {
|
||||
a.write([])
|
||||
}
|
||||
|
||||
fn main(){}
|
||||
|
16
src/test/run-pass/issue-8401.rs
Normal file
16
src/test/run-pass/issue-8401.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.
|
||||
|
||||
// aux-build:issue_8401.rs
|
||||
// xfail-fast
|
||||
|
||||
extern mod issue_8401;
|
||||
|
||||
pub fn main() {}
|
Loading…
x
Reference in New Issue
Block a user