Skip to content

Commit e01cf3c

Browse files
committed
testsuite: Add various test cases
Some are xfailed, some not, some existing ones get un-xfailed.
1 parent b93393e commit e01cf3c

15 files changed

+383
-13
lines changed

src/test/auxiliary/issue_3907_1.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub trait Foo {
2+
fn bar();
3+
}

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test
1211
struct Thing {
1312
x: int
1413
}
1514

16-
impl Mul<int, Thing>*/ for Thing/* { //~ ERROR Look ma, no Mul!
17-
fn mul(c: &int) -> Thing {
15+
impl Thing {
16+
fn mul(&self, c: &int) -> Thing {
1817
Thing {x: self.x * *c}
1918
}
2019
}
2120

2221
fn main() {
2322
let u = Thing {x: 2};
24-
let _v = u.mul(&3); // Works
25-
let w = u * 3; // Works!!
23+
let _v = u.mul(&3); // This is ok
24+
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
2625
io::println(fmt!("%i", w.x));
27-
28-
/*
29-
// This doesn't work though.
30-
let u2 = u as @Mul<int, Thing>;
31-
let w2 = u2.mul(&4);
32-
io::println(fmt!("%i", w2.x));
33-
*/
3426
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
// xfail-test
12-
1312
struct Point {
1413
x: float,
1514
y: float,

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
// xfail-test
12+
struct HasNested {
13+
mut nest: ~[~[int]],
14+
}
15+
16+
impl HasNested {
17+
fn method_push_local(&self) {
18+
self.nest[0].push(0);
19+
}
20+
}
21+
22+
fn main() {}

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

Lines changed: 24 additions & 0 deletions
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+
struct Foo {
12+
baz: uint
13+
}
14+
15+
impl Foo {
16+
fn bar() {
17+
Foo { baz: 0 }.bar();
18+
}
19+
20+
fn bar() { //~ ERROR duplicate definition of value bar
21+
}
22+
}
23+
24+
fn main() {}

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

Lines changed: 19 additions & 0 deletions
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+
// xfail-test
12+
13+
fn main() {
14+
for os::args().each |arg| {
15+
match copy *arg {
16+
s => { }
17+
}
18+
}
19+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
// xfail-test
12+
trait I {}
13+
type K = I;
14+
impl K for int {}
15+
fn main() {}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
// xfail-test
12+
fn main() { fmt!("%?", None); } //~ ERROR can't resolve type variable

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

Lines changed: 14 additions & 0 deletions
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+
12+
trait B < A > { fn a() -> A { self.a} } //~ ERROR unresolved name
13+
14+
fn main() {}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
extern mod std;
12+
use core::io::WriterUtil;
13+
14+
enum Token {
15+
Text(@~str),
16+
ETag(@~[~str], @~str),
17+
UTag(@~[~str], @~str),
18+
Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str),
19+
IncompleteSection(@~[~str], bool, @~str, bool),
20+
Partial(@~str, @~str, @~str),
21+
}
22+
23+
fn check_strs(actual: &str, expected: &str) -> bool
24+
{
25+
if actual != expected
26+
{
27+
io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected));
28+
return false;
29+
}
30+
return true;
31+
}
32+
33+
fn main()
34+
{
35+
// fail_unless!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")"));
36+
// fail_unless!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
37+
38+
let t = Text(@~"foo");
39+
let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo");
40+
let v = fmt!("%?", u); // this is the line that causes the seg fault
41+
fail_unless!(v.len() > 0);
42+
}

0 commit comments

Comments
 (0)