Test cases, some xfailed
This commit is contained in:
parent
10ec058638
commit
35f36808ff
6
src/test/compile-fail/issue-2478.rs
Normal file
6
src/test/compile-fail/issue-2478.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// xfail-test
|
||||
fn foo() -> &a/int {
|
||||
return &x;
|
||||
}
|
||||
const x: int = 5;
|
||||
fn main() {}
|
11
src/test/compile-fail/issue-3154.rs
Normal file
11
src/test/compile-fail/issue-3154.rs
Normal file
@ -0,0 +1,11 @@
|
||||
struct thing<Q> {
|
||||
x: &Q
|
||||
}
|
||||
|
||||
fn thing<Q>(x: &Q) -> thing<Q> {
|
||||
thing{ x: x } //~ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
|
||||
fn main() {
|
||||
thing(&());
|
||||
}
|
11
src/test/compile-fail/issue-3243.rs
Normal file
11
src/test/compile-fail/issue-3243.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// xfail-test
|
||||
fn function() -> &[mut int] {
|
||||
let mut x: &static/[mut int] = &[mut 1,2,3];
|
||||
x[0] = 12345;
|
||||
x //~ ERROR bad
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = function();
|
||||
error!("%?", x);
|
||||
}
|
12
src/test/compile-fail/issue-3296.rs
Normal file
12
src/test/compile-fail/issue-3296.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use std;
|
||||
|
||||
struct Deserializer : std::serialization::deserializer{ //~ ERROR obsolete syntax: class traits
|
||||
x: ()
|
||||
}
|
||||
|
||||
type foo = {a: (),};
|
||||
|
||||
fn deserialize_foo<__D: std::serialization::deserializer>(&&__d: __D) {
|
||||
}
|
||||
|
||||
fn main() { let des = Deserializer(); let foo = deserialize_foo(des); }
|
21
src/test/compile-fail/issue-3311.rs
Normal file
21
src/test/compile-fail/issue-3311.rs
Normal file
@ -0,0 +1,21 @@
|
||||
#[legacy_mode]
|
||||
struct Foo {
|
||||
s: &str,
|
||||
u: ~()
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn get_s(&self) -> &self/str {
|
||||
self.s
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(s: &str, f: fn(Option<Foo>)) {
|
||||
f(Some(Foo {s: s, u: ~()}));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
do bar(~"testing") |opt| {
|
||||
io::println(option::unwrap(opt).get_s()); //~ ERROR illegal borrow:
|
||||
};
|
||||
}
|
6
src/test/compile-fail/issue-3680.rs
Normal file
6
src/test/compile-fail/issue-3680.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// xfail-test
|
||||
fn f() {
|
||||
match None {
|
||||
Err(_) => () //~ ERROR expected `core::result
|
||||
}
|
||||
}
|
13
src/test/compile-fail/issue-3702-2.rs
Normal file
13
src/test/compile-fail/issue-3702-2.rs
Normal file
@ -0,0 +1,13 @@
|
||||
trait Add {
|
||||
fn to_int(&self) -> int;
|
||||
fn add_dynamic(&self, other: &Add) -> int;
|
||||
}
|
||||
|
||||
impl int: Add {
|
||||
fn to_int(&self) -> int { *self }
|
||||
fn add_dynamic(&self, other: &Add) -> int {
|
||||
self.to_int() + other.to_int() //~ ERROR multiple applicable methods in scope
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
BIN
src/test/compile-fail/issue-3763
Executable file
BIN
src/test/compile-fail/issue-3763
Executable file
Binary file not shown.
17
src/test/compile-fail/issue-3763.rs
Normal file
17
src/test/compile-fail/issue-3763.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// xfail-test
|
||||
mod my_mod {
|
||||
pub struct MyStruct {
|
||||
priv priv_field: int
|
||||
}
|
||||
pub fn MyStruct () -> MyStruct {
|
||||
MyStruct {priv_field: 4}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let my_struct = my_mod::MyStruct();
|
||||
let _woohoo = (&my_struct).priv_field; // compiles but shouldn't
|
||||
let _woohoo = (~my_struct).priv_field; // ditto
|
||||
let _woohoo = (@my_struct).priv_field; // ditto
|
||||
// let nope = my_struct.priv_field; // compile error as expected
|
||||
}
|
9
src/test/run-pass/issue-3026.rs
Normal file
9
src/test/run-pass/issue-3026.rs
Normal file
@ -0,0 +1,9 @@
|
||||
extern mod std;
|
||||
use std::map::HashMap;
|
||||
use std::map;
|
||||
|
||||
fn main() {
|
||||
let buggy_map :HashMap<uint, &uint> = HashMap::<uint, &uint>();
|
||||
let x = ~1;
|
||||
buggy_map.insert(42, x);
|
||||
}
|
11
src/test/run-pass/issue-3052.rs
Normal file
11
src/test/run-pass/issue-3052.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use option::*;
|
||||
|
||||
type Connection = fn@(~[u8]);
|
||||
|
||||
fn f() -> Option<Connection> {
|
||||
let mock_connection: Connection = fn@(_data: ~[u8]) { };
|
||||
Some(mock_connection)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
3
src/test/run-pass/issue-3109.rs
Normal file
3
src/test/run-pass/issue-3109.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
log(error, ("hi there!", "you"));
|
||||
}
|
22
src/test/run-pass/issue-3389.rs
Normal file
22
src/test/run-pass/issue-3389.rs
Normal file
@ -0,0 +1,22 @@
|
||||
struct trie_node {
|
||||
mut content: ~[~str],
|
||||
mut children: ~[trie_node],
|
||||
}
|
||||
|
||||
fn print_str_vector(vector: ~[~str]) {
|
||||
for vector.each() |string| {
|
||||
io::println(*string);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let node: trie_node = trie_node {
|
||||
content: ~[],
|
||||
children: ~[]
|
||||
};
|
||||
let v = ~[~"123", ~"abc"];
|
||||
node.content = ~[~"123", ~"abc"];
|
||||
print_str_vector(v);
|
||||
print_str_vector(copy node.content);
|
||||
|
||||
}
|
16
src/test/run-pass/issue-3424.rs
Normal file
16
src/test/run-pass/issue-3424.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// rustc --test ignores2.rs && ./ignores2
|
||||
extern mod std;
|
||||
use path::{Path};
|
||||
|
||||
type rsrc_loader = fn~ (path: &Path) -> result::Result<~str, ~str>;
|
||||
|
||||
#[test]
|
||||
fn tester()
|
||||
{
|
||||
let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};
|
||||
|
||||
let path = path::from_str("blah");
|
||||
assert loader(&path).is_ok();
|
||||
}
|
||||
|
||||
fn main() {}
|
7
src/test/run-pass/issue-3461.rs
Normal file
7
src/test/run-pass/issue-3461.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// xfail-test
|
||||
fn main() {
|
||||
|
||||
fn foo() { }
|
||||
|
||||
let bar: ~fn() = ~foo;
|
||||
}
|
17
src/test/run-pass/issue-3480.rs
Normal file
17
src/test/run-pass/issue-3480.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// xfail-test
|
||||
type IMap<K: Copy, V: Copy> = ~[(K, V)];
|
||||
|
||||
trait ImmutableMap<K: Copy, V: Copy>
|
||||
{
|
||||
pure fn contains_key(key: K) -> bool;
|
||||
}
|
||||
|
||||
impl<K: Copy, V: Copy> IMap<K, V> : ImmutableMap<K, V>
|
||||
{
|
||||
pure fn contains_key(key: K) -> bool
|
||||
{
|
||||
vec::find(self, |e| {e.first() == key}).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
7
src/test/run-pass/issue-3500.rs
Normal file
7
src/test/run-pass/issue-3500.rs
Normal file
@ -0,0 +1,7 @@
|
||||
fn main() {
|
||||
let x = &Some(1);
|
||||
match x {
|
||||
&Some(_) => (),
|
||||
&None => (),
|
||||
}
|
||||
}
|
BIN
src/test/run-pass/issue-3559
Executable file
BIN
src/test/run-pass/issue-3559
Executable file
Binary file not shown.
26
src/test/run-pass/issue-3559.rs
Normal file
26
src/test/run-pass/issue-3559.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// rustc --test map_to_str.rs && ./map_to_str
|
||||
extern mod std;
|
||||
use io::{WriterUtil};
|
||||
use std::map::*;
|
||||
|
||||
#[cfg(test)]
|
||||
fn check_strs(actual: &str, expected: &str) -> bool
|
||||
{
|
||||
if actual != expected
|
||||
{
|
||||
io::stderr().write_line(fmt!("Found %s, but expected %s", actual, expected));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tester()
|
||||
{
|
||||
let table = HashMap();
|
||||
table.insert(@~"one", 1);
|
||||
table.insert(@~"two", 2);
|
||||
assert check_strs(table.to_str(), ~"xxx"); // not sure what expected should be
|
||||
}
|
||||
|
||||
fn main() {}
|
6
src/test/run-pass/issue-3563.rs
Normal file
6
src/test/run-pass/issue-3563.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// xfail-test
|
||||
trait A {
|
||||
fn a(&self) {
|
||||
|| self.b()
|
||||
}
|
||||
}
|
18
src/test/run-pass/issue-3574.rs
Normal file
18
src/test/run-pass/issue-3574.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// xfail-test
|
||||
// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
|
||||
extern mod std;
|
||||
|
||||
fn compare(x: &str, y: &str) -> bool
|
||||
{
|
||||
match x
|
||||
{
|
||||
"foo" => y == "foo",
|
||||
_ => y == "bar",
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tester()
|
||||
{
|
||||
assert compare("foo", "foo");
|
||||
}
|
BIN
src/test/run-pass/issue-3702
Executable file
BIN
src/test/run-pass/issue-3702
Executable file
Binary file not shown.
12
src/test/run-pass/issue-3702.rs
Normal file
12
src/test/run-pass/issue-3702.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use io::println;
|
||||
|
||||
fn main() {
|
||||
trait Text {
|
||||
fn to_str(&self) -> ~str;
|
||||
}
|
||||
|
||||
fn to_string(t: Text) {
|
||||
println(t.to_str());
|
||||
}
|
||||
|
||||
}
|
30
src/test/run-pass/issue-3794.rs
Normal file
30
src/test/run-pass/issue-3794.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// xfail-test
|
||||
trait T {
|
||||
fn print(&self);
|
||||
}
|
||||
|
||||
struct S {
|
||||
s: int,
|
||||
}
|
||||
|
||||
impl S: T {
|
||||
fn print(&self) {
|
||||
io::println(fmt!("%?", self));
|
||||
}
|
||||
}
|
||||
|
||||
fn print_t(t: &T) {
|
||||
t.print();
|
||||
}
|
||||
|
||||
fn print_s(s: &S) {
|
||||
s.print();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s: @S = @S { s: 5 };
|
||||
print_s(s);
|
||||
let t: @T = s as @T;
|
||||
print_t(t);
|
||||
|
||||
}
|
19
src/test/run-pass/issue-3860.rs
Normal file
19
src/test/run-pass/issue-3860.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// xfail-test
|
||||
struct Foo { x: int }
|
||||
|
||||
impl Foo {
|
||||
fn stuff(&mut self) -> &self/mut Foo {
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = @mut Foo { x: 3 };
|
||||
x.stuff(); // error: internal compiler error: no enclosing scope with id 49
|
||||
// storing the result removes the error, so replacing the above
|
||||
// with the following, works:
|
||||
// let _y = x.stuff()
|
||||
|
||||
// also making 'stuff()' not return anything fixes it
|
||||
// I guess the "dangling &ptr" cuases issues?
|
||||
}
|
BIN
src/test/run-pass/issue-4016
Executable file
BIN
src/test/run-pass/issue-4016
Executable file
Binary file not shown.
17
src/test/run-pass/issue-4016.rs
Normal file
17
src/test/run-pass/issue-4016.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// xfail-test
|
||||
extern mod std;
|
||||
|
||||
use send_map::linear;
|
||||
use std::json;
|
||||
use std::serialization::{Deserializable, deserialize};
|
||||
|
||||
trait JD : Deserializable<json::Deserializer> { }
|
||||
//type JD = Deserializable<json::Deserializer>;
|
||||
|
||||
fn exec<T: JD>() {
|
||||
let doc = result::unwrap(json::from_str(""));
|
||||
let _v: T = deserialize(&json::Deserializer(move doc));
|
||||
fail
|
||||
}
|
||||
|
||||
fn main() {}
|
BIN
src/test/run-pass/issue-4092
Executable file
BIN
src/test/run-pass/issue-4092
Executable file
Binary file not shown.
6
src/test/run-pass/issue-4092.rs
Normal file
6
src/test/run-pass/issue-4092.rs
Normal file
@ -0,0 +1,6 @@
|
||||
extern mod std;
|
||||
|
||||
fn main() {
|
||||
let x = std::map::HashMap();
|
||||
x.insert((@"abc", 0), 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user