Skip to content

Commit 35f3680

Browse files
committed
Test cases, some xfailed
1 parent 10ec058 commit 35f3680

29 files changed

+323
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// xfail-test
2+
fn foo() -> &a/int {
3+
return &x;
4+
}
5+
const x: int = 5;
6+
fn main() {}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
struct thing<Q> {
2+
x: &Q
3+
}
4+
5+
fn thing<Q>(x: &Q) -> thing<Q> {
6+
thing{ x: x } //~ ERROR cannot infer an appropriate lifetime
7+
}
8+
9+
fn main() {
10+
thing(&());
11+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// xfail-test
2+
fn function() -> &[mut int] {
3+
let mut x: &static/[mut int] = &[mut 1,2,3];
4+
x[0] = 12345;
5+
x //~ ERROR bad
6+
}
7+
8+
fn main() {
9+
let x = function();
10+
error!("%?", x);
11+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use std;
2+
3+
struct Deserializer : std::serialization::deserializer{ //~ ERROR obsolete syntax: class traits
4+
x: ()
5+
}
6+
7+
type foo = {a: (),};
8+
9+
fn deserialize_foo<__D: std::serialization::deserializer>(&&__d: __D) {
10+
}
11+
12+
fn main() { let des = Deserializer(); let foo = deserialize_foo(des); }

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#[legacy_mode]
2+
struct Foo {
3+
s: &str,
4+
u: ~()
5+
}
6+
7+
impl Foo {
8+
fn get_s(&self) -> &self/str {
9+
self.s
10+
}
11+
}
12+
13+
fn bar(s: &str, f: fn(Option<Foo>)) {
14+
f(Some(Foo {s: s, u: ~()}));
15+
}
16+
17+
fn main() {
18+
do bar(~"testing") |opt| {
19+
io::println(option::unwrap(opt).get_s()); //~ ERROR illegal borrow:
20+
};
21+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// xfail-test
2+
fn f() {
3+
match None {
4+
Err(_) => () //~ ERROR expected `core::result
5+
}
6+
}

src/test/compile-fail/issue-3702-2.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Add {
2+
fn to_int(&self) -> int;
3+
fn add_dynamic(&self, other: &Add) -> int;
4+
}
5+
6+
impl int: Add {
7+
fn to_int(&self) -> int { *self }
8+
fn add_dynamic(&self, other: &Add) -> int {
9+
self.to_int() + other.to_int() //~ ERROR multiple applicable methods in scope
10+
}
11+
}
12+
13+
fn main() { }

src/test/compile-fail/issue-3763

14.7 KB
Binary file not shown.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// xfail-test
2+
mod my_mod {
3+
pub struct MyStruct {
4+
priv priv_field: int
5+
}
6+
pub fn MyStruct () -> MyStruct {
7+
MyStruct {priv_field: 4}
8+
}
9+
}
10+
11+
fn main() {
12+
let my_struct = my_mod::MyStruct();
13+
let _woohoo = (&my_struct).priv_field; // compiles but shouldn't
14+
let _woohoo = (~my_struct).priv_field; // ditto
15+
let _woohoo = (@my_struct).priv_field; // ditto
16+
// let nope = my_struct.priv_field; // compile error as expected
17+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extern mod std;
2+
use std::map::HashMap;
3+
use std::map;
4+
5+
fn main() {
6+
let buggy_map :HashMap<uint, &uint> = HashMap::<uint, &uint>();
7+
let x = ~1;
8+
buggy_map.insert(42, x);
9+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use option::*;
2+
3+
type Connection = fn@(~[u8]);
4+
5+
fn f() -> Option<Connection> {
6+
let mock_connection: Connection = fn@(_data: ~[u8]) { };
7+
Some(mock_connection)
8+
}
9+
10+
fn main() {
11+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
log(error, ("hi there!", "you"));
3+
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct trie_node {
2+
mut content: ~[~str],
3+
mut children: ~[trie_node],
4+
}
5+
6+
fn print_str_vector(vector: ~[~str]) {
7+
for vector.each() |string| {
8+
io::println(*string);
9+
}
10+
}
11+
12+
fn main() {
13+
let node: trie_node = trie_node {
14+
content: ~[],
15+
children: ~[]
16+
};
17+
let v = ~[~"123", ~"abc"];
18+
node.content = ~[~"123", ~"abc"];
19+
print_str_vector(v);
20+
print_str_vector(copy node.content);
21+
22+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// rustc --test ignores2.rs && ./ignores2
2+
extern mod std;
3+
use path::{Path};
4+
5+
type rsrc_loader = fn~ (path: &Path) -> result::Result<~str, ~str>;
6+
7+
#[test]
8+
fn tester()
9+
{
10+
let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};
11+
12+
let path = path::from_str("blah");
13+
assert loader(&path).is_ok();
14+
}
15+
16+
fn main() {}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// xfail-test
2+
fn main() {
3+
4+
fn foo() { }
5+
6+
let bar: ~fn() = ~foo;
7+
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// xfail-test
2+
type IMap<K: Copy, V: Copy> = ~[(K, V)];
3+
4+
trait ImmutableMap<K: Copy, V: Copy>
5+
{
6+
pure fn contains_key(key: K) -> bool;
7+
}
8+
9+
impl<K: Copy, V: Copy> IMap<K, V> : ImmutableMap<K, V>
10+
{
11+
pure fn contains_key(key: K) -> bool
12+
{
13+
vec::find(self, |e| {e.first() == key}).is_some()
14+
}
15+
}
16+
17+
fn main() {}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
let x = &Some(1);
3+
match x {
4+
&Some(_) => (),
5+
&None => (),
6+
}
7+
}

src/test/run-pass/issue-3559

9.53 KB
Binary file not shown.

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// rustc --test map_to_str.rs && ./map_to_str
2+
extern mod std;
3+
use io::{WriterUtil};
4+
use std::map::*;
5+
6+
#[cfg(test)]
7+
fn check_strs(actual: &str, expected: &str) -> bool
8+
{
9+
if actual != expected
10+
{
11+
io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected));
12+
return false;
13+
}
14+
return true;
15+
}
16+
17+
#[test]
18+
fn tester()
19+
{
20+
let table = HashMap();
21+
table.insert(@~"one", 1);
22+
table.insert(@~"two", 2);
23+
assert check_strs(table.to_str(), ~"xxx"); // not sure what expected should be
24+
}
25+
26+
fn main() {}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// xfail-test
2+
trait A {
3+
fn a(&self) {
4+
|| self.b()
5+
}
6+
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// xfail-test
2+
// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
3+
extern mod std;
4+
5+
fn compare(x: &str, y: &str) -> bool
6+
{
7+
match x
8+
{
9+
"foo" => y == "foo",
10+
_ => y == "bar",
11+
}
12+
}
13+
14+
#[test]
15+
fn tester()
16+
{
17+
assert compare("foo", "foo");
18+
}

src/test/run-pass/issue-3702

14.4 KB
Binary file not shown.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use io::println;
2+
3+
fn main() {
4+
trait Text {
5+
fn to_str(&self) -> ~str;
6+
}
7+
8+
fn to_string(t: Text) {
9+
println(t.to_str());
10+
}
11+
12+
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// xfail-test
2+
trait T {
3+
fn print(&self);
4+
}
5+
6+
struct S {
7+
s: int,
8+
}
9+
10+
impl S: T {
11+
fn print(&self) {
12+
io::println(fmt!("%?", self));
13+
}
14+
}
15+
16+
fn print_t(t: &T) {
17+
t.print();
18+
}
19+
20+
fn print_s(s: &S) {
21+
s.print();
22+
}
23+
24+
fn main() {
25+
let s: @S = @S { s: 5 };
26+
print_s(s);
27+
let t: @T = s as @T;
28+
print_t(t);
29+
30+
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// xfail-test
2+
struct Foo { x: int }
3+
4+
impl Foo {
5+
fn stuff(&mut self) -> &self/mut Foo {
6+
return self;
7+
}
8+
}
9+
10+
fn main() {
11+
let mut x = @mut Foo { x: 3 };
12+
x.stuff(); // error: internal compiler error: no enclosing scope with id 49
13+
// storing the result removes the error, so replacing the above
14+
// with the following, works:
15+
// let _y = x.stuff()
16+
17+
// also making 'stuff()' not return anything fixes it
18+
// I guess the "dangling &ptr" cuases issues?
19+
}

src/test/run-pass/issue-4016

9.53 KB
Binary file not shown.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// xfail-test
2+
extern mod std;
3+
4+
use send_map::linear;
5+
use std::json;
6+
use std::serialization::{Deserializable, deserialize};
7+
8+
trait JD : Deserializable<json::Deserializer> { }
9+
//type JD = Deserializable<json::Deserializer>;
10+
11+
fn exec<T: JD>() {
12+
let doc = result::unwrap(json::from_str(""));
13+
let _v: T = deserialize(&json::Deserializer(move doc));
14+
fail
15+
}
16+
17+
fn main() {}

src/test/run-pass/issue-4092

93.8 KB
Binary file not shown.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extern mod std;
2+
3+
fn main() {
4+
let x = std::map::HashMap();
5+
x.insert((@"abc", 0), 0);
6+
}

0 commit comments

Comments
 (0)