diff --git a/src/test/compile-fail/issue-2478.rs b/src/test/compile-fail/issue-2478.rs new file mode 100644 index 00000000000..bab93b176b5 --- /dev/null +++ b/src/test/compile-fail/issue-2478.rs @@ -0,0 +1,6 @@ +// xfail-test +fn foo() -> &a/int { + return &x; +} +const x: int = 5; +fn main() {} diff --git a/src/test/compile-fail/issue-3154.rs b/src/test/compile-fail/issue-3154.rs new file mode 100644 index 00000000000..1208f80e4c6 --- /dev/null +++ b/src/test/compile-fail/issue-3154.rs @@ -0,0 +1,11 @@ +struct thing { + x: &Q +} + +fn thing(x: &Q) -> thing { + thing{ x: x } //~ ERROR cannot infer an appropriate lifetime +} + +fn main() { + thing(&()); +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-3243.rs b/src/test/compile-fail/issue-3243.rs new file mode 100644 index 00000000000..a2ad89c86ba --- /dev/null +++ b/src/test/compile-fail/issue-3243.rs @@ -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); +} \ No newline at end of file diff --git a/src/test/compile-fail/issue-3296.rs b/src/test/compile-fail/issue-3296.rs new file mode 100644 index 00000000000..35b74e9a4d3 --- /dev/null +++ b/src/test/compile-fail/issue-3296.rs @@ -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); } diff --git a/src/test/compile-fail/issue-3311.rs b/src/test/compile-fail/issue-3311.rs new file mode 100644 index 00000000000..3f0c7bcfdb3 --- /dev/null +++ b/src/test/compile-fail/issue-3311.rs @@ -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)) { + f(Some(Foo {s: s, u: ~()})); +} + +fn main() { + do bar(~"testing") |opt| { + io::println(option::unwrap(opt).get_s()); //~ ERROR illegal borrow: + }; +} diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs new file mode 100644 index 00000000000..e2f40364b61 --- /dev/null +++ b/src/test/compile-fail/issue-3680.rs @@ -0,0 +1,6 @@ +// xfail-test +fn f() { + match None { + Err(_) => () //~ ERROR expected `core::result + } +} diff --git a/src/test/compile-fail/issue-3702-2.rs b/src/test/compile-fail/issue-3702-2.rs new file mode 100644 index 00000000000..cf44a6cbe9a --- /dev/null +++ b/src/test/compile-fail/issue-3702-2.rs @@ -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() { } diff --git a/src/test/compile-fail/issue-3763 b/src/test/compile-fail/issue-3763 new file mode 100755 index 00000000000..4415d099181 Binary files /dev/null and b/src/test/compile-fail/issue-3763 differ diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs new file mode 100644 index 00000000000..46e47081f3a --- /dev/null +++ b/src/test/compile-fail/issue-3763.rs @@ -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 +} diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs new file mode 100644 index 00000000000..8345aac5a0e --- /dev/null +++ b/src/test/run-pass/issue-3026.rs @@ -0,0 +1,9 @@ +extern mod std; +use std::map::HashMap; +use std::map; + +fn main() { + let buggy_map :HashMap = HashMap::(); + let x = ~1; + buggy_map.insert(42, x); +} diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs new file mode 100644 index 00000000000..52c3dfb984a --- /dev/null +++ b/src/test/run-pass/issue-3052.rs @@ -0,0 +1,11 @@ +use option::*; + +type Connection = fn@(~[u8]); + +fn f() -> Option { + let mock_connection: Connection = fn@(_data: ~[u8]) { }; + Some(mock_connection) +} + +fn main() { +} diff --git a/src/test/run-pass/issue-3109.rs b/src/test/run-pass/issue-3109.rs new file mode 100644 index 00000000000..5bf16ef5097 --- /dev/null +++ b/src/test/run-pass/issue-3109.rs @@ -0,0 +1,3 @@ +fn main() { + log(error, ("hi there!", "you")); +} diff --git a/src/test/run-pass/issue-3389.rs b/src/test/run-pass/issue-3389.rs new file mode 100644 index 00000000000..57f8e71899d --- /dev/null +++ b/src/test/run-pass/issue-3389.rs @@ -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); + +} diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs new file mode 100644 index 00000000000..bfc683fd9ae --- /dev/null +++ b/src/test/run-pass/issue-3424.rs @@ -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() {} diff --git a/src/test/run-pass/issue-3461.rs b/src/test/run-pass/issue-3461.rs new file mode 100644 index 00000000000..30a865d2c00 --- /dev/null +++ b/src/test/run-pass/issue-3461.rs @@ -0,0 +1,7 @@ +// xfail-test +fn main() { + + fn foo() { } + + let bar: ~fn() = ~foo; +} \ No newline at end of file diff --git a/src/test/run-pass/issue-3480.rs b/src/test/run-pass/issue-3480.rs new file mode 100644 index 00000000000..1781b6bbf6e --- /dev/null +++ b/src/test/run-pass/issue-3480.rs @@ -0,0 +1,17 @@ +// xfail-test +type IMap = ~[(K, V)]; + +trait ImmutableMap +{ + pure fn contains_key(key: K) -> bool; +} + +impl IMap : ImmutableMap +{ + pure fn contains_key(key: K) -> bool + { + vec::find(self, |e| {e.first() == key}).is_some() + } +} + +fn main() {} \ No newline at end of file diff --git a/src/test/run-pass/issue-3500.rs b/src/test/run-pass/issue-3500.rs new file mode 100644 index 00000000000..f42c5f193ce --- /dev/null +++ b/src/test/run-pass/issue-3500.rs @@ -0,0 +1,7 @@ +fn main() { + let x = &Some(1); + match x { + &Some(_) => (), + &None => (), + } +} diff --git a/src/test/run-pass/issue-3559 b/src/test/run-pass/issue-3559 new file mode 100755 index 00000000000..406e055884a Binary files /dev/null and b/src/test/run-pass/issue-3559 differ diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs new file mode 100644 index 00000000000..25629961276 --- /dev/null +++ b/src/test/run-pass/issue-3559.rs @@ -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() {} diff --git a/src/test/run-pass/issue-3563.rs b/src/test/run-pass/issue-3563.rs new file mode 100644 index 00000000000..e05e62c60e1 --- /dev/null +++ b/src/test/run-pass/issue-3563.rs @@ -0,0 +1,6 @@ +// xfail-test +trait A { + fn a(&self) { + || self.b() + } +} diff --git a/src/test/run-pass/issue-3574.rs b/src/test/run-pass/issue-3574.rs new file mode 100644 index 00000000000..236ee1b6407 --- /dev/null +++ b/src/test/run-pass/issue-3574.rs @@ -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"); +} diff --git a/src/test/run-pass/issue-3702 b/src/test/run-pass/issue-3702 new file mode 100755 index 00000000000..3f39ee31442 Binary files /dev/null and b/src/test/run-pass/issue-3702 differ diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs new file mode 100644 index 00000000000..e790b97d618 --- /dev/null +++ b/src/test/run-pass/issue-3702.rs @@ -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()); + } + +} diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs new file mode 100644 index 00000000000..3669929e139 --- /dev/null +++ b/src/test/run-pass/issue-3794.rs @@ -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); + +} diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs new file mode 100644 index 00000000000..da6d6aeda37 --- /dev/null +++ b/src/test/run-pass/issue-3860.rs @@ -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? +} diff --git a/src/test/run-pass/issue-4016 b/src/test/run-pass/issue-4016 new file mode 100755 index 00000000000..ff979383c10 Binary files /dev/null and b/src/test/run-pass/issue-4016 differ diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass/issue-4016.rs new file mode 100644 index 00000000000..1e998b1f42e --- /dev/null +++ b/src/test/run-pass/issue-4016.rs @@ -0,0 +1,17 @@ +// xfail-test +extern mod std; + +use send_map::linear; +use std::json; +use std::serialization::{Deserializable, deserialize}; + +trait JD : Deserializable { } +//type JD = Deserializable; + +fn exec() { + let doc = result::unwrap(json::from_str("")); + let _v: T = deserialize(&json::Deserializer(move doc)); + fail +} + +fn main() {} diff --git a/src/test/run-pass/issue-4092 b/src/test/run-pass/issue-4092 new file mode 100755 index 00000000000..761b6ab4686 Binary files /dev/null and b/src/test/run-pass/issue-4092 differ diff --git a/src/test/run-pass/issue-4092.rs b/src/test/run-pass/issue-4092.rs new file mode 100644 index 00000000000..8198abb8ddc --- /dev/null +++ b/src/test/run-pass/issue-4092.rs @@ -0,0 +1,6 @@ +extern mod std; + +fn main() { + let x = std::map::HashMap(); + x.insert((@"abc", 0), 0); +}