Skip to content

Commit c4656cf

Browse files
committed
auto merge of rust-lang#8485 : alexcrichton/rust/add-tests, r=catamorphism
Closes rust-lang#3907 Closes rust-lang#5493 Closes rust-lang#4464 Closes rust-lang#4759 Closes rust-lang#5666 Closes rust-lang#5884 Closes rust-lang#5926 Closes rust-lang#6318 Closes rust-lang#6557 Closes rust-lang#6898 Closes rust-lang#6919 Closes rust-lang#7222
2 parents 5c0d192 + 1764e20 commit c4656cf

21 files changed

+446
-1
lines changed

src/libstd/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ string.
9393
Because formatting is done via traits, there is no requirement that the
9494
`d` format actually takes an `int`, but rather it simply requires a type which
9595
ascribes to the `Signed` formatting trait. There are various parameters which do
96-
require a particular type, however. Namely if the sytnax `{:.*s}` is used, then
96+
require a particular type, however. Namely if the syntax `{:.*s}` is used, then
9797
the number of characters to print from the string precedes the actual string and
9898
must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is
9999
illegal to reference an argument as such. For example, this is another invalid

src/test/auxiliary/iss.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
#[link(name="iss6919_3", vers="0.1")];
12+
13+
// part of issue-6919.rs
14+
15+
struct C<'self> {
16+
k: &'self fn(),
17+
}
18+
19+
fn no_op() { }
20+
pub static D : C<'static> = C {
21+
k: no_op
22+
};
23+

src/test/auxiliary/issue_3907.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
pub trait Foo {
12+
fn bar();
13+
}
14+

src/test/auxiliary/issue_8401.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
// for this issue, this code must be built in a library
12+
13+
use std::cast;
14+
15+
trait A {}
16+
struct B;
17+
impl A for B {}
18+
19+
fn bar<T>(_: &mut A, _: &T) {}
20+
21+
fn foo<T>(t: &T) {
22+
let b = B;
23+
bar(unsafe { cast::transmute(&b as &A) }, t)
24+
}
25+

src/test/compile-fail/issue-3907.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
// aux-build:issue_3907.rs
12+
extern mod issue_3907;
13+
14+
type Foo = issue_3907::Foo; //~ ERROR: reference to trait
15+
16+
struct S {
17+
name: int
18+
}
19+
20+
impl Foo for S { //~ ERROR: Foo is not a trait
21+
fn bar() { }
22+
}
23+
24+
fn main() {
25+
let s = S {
26+
name: 0
27+
};
28+
s.bar();
29+
}
30+

src/test/compile-fail/issue-5439.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
struct Foo {
12+
foo: int,
13+
}
14+
15+
struct Bar {
16+
bar: int,
17+
}
18+
19+
impl Bar {
20+
fn make_foo (&self, i: int) -> ~Foo {
21+
return ~Foo { nonexistent: self, foo: i }; //~ ERROR: no field named
22+
}
23+
}
24+
25+
fn main () {
26+
let bar = Bar { bar: 1 };
27+
let foo = bar.make_foo(2);
28+
println(fmt!("%d", foo.foo));
29+
}

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

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
fn broken<'r>(v: &'r [u8], i: uint, j: uint) -> &'r [u8] { v.slice(i, j) }
12+
13+
pub fn main() {}

src/test/run-pass/issue-4759-1.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
trait U { fn f(self); }
12+
impl U for int { fn f(self) {} }
13+
pub fn main() { 4.f(); }

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

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
struct T { a: ~int }
12+
13+
trait U {
14+
fn f(self);
15+
}
16+
17+
impl U for ~int {
18+
fn f(self) { }
19+
}
20+
21+
pub fn main() {
22+
let T { a: a } = T { a: ~0 };
23+
a.f();
24+
}
25+

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

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
struct Dog {
12+
name : ~str
13+
}
14+
15+
trait Barks {
16+
fn bark(&self) -> ~str;
17+
}
18+
19+
impl Barks for Dog {
20+
fn bark(&self) -> ~str {
21+
return fmt!("woof! (I'm %s)", self.name);
22+
}
23+
}
24+
25+
26+
pub fn main() {
27+
let snoopy = ~Dog{name: ~"snoopy"};
28+
let bubbles = ~Dog{name: ~"bubbles"};
29+
let barker = [snoopy as ~Barks, bubbles as ~Barks];
30+
31+
for pup in barker.iter() {
32+
println(fmt!("%s", pup.bark()));
33+
}
34+
}
35+

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
pub struct Foo {
12+
a: int,
13+
}
14+
15+
struct Bar<'self> {
16+
a: ~Option<int>,
17+
b: &'self Foo,
18+
}
19+
20+
fn check(a: @Foo) {
21+
let mut _ic = Bar{ b: a, a: ~None };
22+
}
23+
24+
pub fn main(){}

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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
pub fn main() {
12+
let mut your_favorite_numbers = @[1,2,3];
13+
let mut my_favorite_numbers = @[4,5,6];
14+
let f = your_favorite_numbers + my_favorite_numbers;
15+
println(fmt!("The third favorite number is %?.", f))
16+
}
17+

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

+26
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+
pub enum Thing {
12+
A(~Foo)
13+
}
14+
15+
pub trait Foo {}
16+
17+
pub struct Struct;
18+
19+
impl Foo for Struct {}
20+
21+
pub fn main() {
22+
match A(~Struct as ~Foo) {
23+
A(a) => 0,
24+
};
25+
}
26+

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

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
fn foo(~(x, y): ~(int, int)) {}
12+
13+
pub fn main() {}

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

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
use std::unstable::intrinsics;
12+
13+
/// Returns the size of a type
14+
pub fn size_of<T>() -> uint {
15+
TypeInfo::size_of::<T>()
16+
}
17+
18+
/// Returns the size of the type that `val` points to
19+
pub fn size_of_val<T>(val: &T) -> uint {
20+
val.size_of_val()
21+
}
22+
23+
pub trait TypeInfo {
24+
fn size_of() -> uint;
25+
fn size_of_val(&self) -> uint;
26+
}
27+
28+
impl<T> TypeInfo for T {
29+
/// The size of the type in bytes.
30+
fn size_of() -> uint {
31+
unsafe { intrinsics::size_of::<T>() }
32+
}
33+
34+
/// Returns the size of the type of `self` in bytes.
35+
fn size_of_val(&self) -> uint {
36+
TypeInfo::size_of::<T>()
37+
}
38+
}
39+
40+
pub fn main() {}

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
// aux-build:iss.rs
12+
// xfail-fast
13+
14+
extern mod iss ( name = "iss6919_3" );
15+
16+
pub fn main() {
17+
iss::D.k;
18+
}
19+

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
pub fn main() {
12+
static FOO: float = 10.0;
13+
14+
match 0.0 {
15+
0.0 .. FOO => (),
16+
_ => ()
17+
}
18+
}
19+

0 commit comments

Comments
 (0)