diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-03-21 15:00:29 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-03-27 10:09:02 -0700 |
| commit | e01cf3caf534a5fe7767fef9e14e8cde2f63f1d2 (patch) | |
| tree | 419611d1c9dd39d58176339933f169fcde910eec | |
| parent | b93393e907eddab513fa2be541af4356b8203282 (diff) | |
| download | rust-e01cf3caf534a5fe7767fef9e14e8cde2f63f1d2.tar.gz rust-e01cf3caf534a5fe7767fef9e14e8cde2f63f1d2.zip | |
testsuite: Add various test cases
Some are xfailed, some not, some existing ones get un-xfailed.
| -rw-r--r-- | src/test/auxiliary/issue_3907_1.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-3820.rs | 16 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-3973.rs | 1 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-3991.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-4265.rs | 24 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-4542.rs | 19 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5035.rs | 15 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5062.rs | 12 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-5099.rs | 14 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3556.rs | 42 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3907-2.rs | 30 | ||||
| -rw-r--r-- | src/test/run-pass/issue-4241.rs | 126 | ||||
| -rw-r--r-- | src/test/run-pass/issue-4252.rs | 37 | ||||
| -rw-r--r-- | src/test/run-pass/issue-4387.rs | 13 | ||||
| -rw-r--r-- | src/test/run-pass/unconstrained-region.rs | 22 |
15 files changed, 383 insertions, 13 deletions
diff --git a/src/test/auxiliary/issue_3907_1.rs b/src/test/auxiliary/issue_3907_1.rs new file mode 100644 index 00000000000..4cc36773f52 --- /dev/null +++ b/src/test/auxiliary/issue_3907_1.rs @@ -0,0 +1,3 @@ +pub trait Foo { + fn bar(); +} diff --git a/src/test/compile-fail/issue-3820.rs b/src/test/compile-fail/issue-3820.rs index 68c00494b9b..2bd11b5111a 100644 --- a/src/test/compile-fail/issue-3820.rs +++ b/src/test/compile-fail/issue-3820.rs @@ -8,27 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test struct Thing { x: int } -impl Mul<int, Thing>*/ for Thing/* { //~ ERROR Look ma, no Mul! - fn mul(c: &int) -> Thing { +impl Thing { + fn mul(&self, c: &int) -> Thing { Thing {x: self.x * *c} } } fn main() { let u = Thing {x: 2}; - let _v = u.mul(&3); // Works - let w = u * 3; // Works!! + let _v = u.mul(&3); // This is ok + let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing` io::println(fmt!("%i", w.x)); - - /* - // This doesn't work though. - let u2 = u as @Mul<int, Thing>; - let w2 = u2.mul(&4); - io::println(fmt!("%i", w2.x)); - */ } diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs index b1d741f9186..a5eaf25aa9f 100644 --- a/src/test/compile-fail/issue-3973.rs +++ b/src/test/compile-fail/issue-3973.rs @@ -9,7 +9,6 @@ // except according to those terms. // xfail-test - struct Point { x: float, y: float, diff --git a/src/test/compile-fail/issue-3991.rs b/src/test/compile-fail/issue-3991.rs new file mode 100644 index 00000000000..d1c9057b880 --- /dev/null +++ b/src/test/compile-fail/issue-3991.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +struct HasNested { + mut nest: ~[~[int]], +} + +impl HasNested { + fn method_push_local(&self) { + self.nest[0].push(0); + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-4265.rs b/src/test/compile-fail/issue-4265.rs new file mode 100644 index 00000000000..b6a32f5feba --- /dev/null +++ b/src/test/compile-fail/issue-4265.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + baz: uint +} + +impl Foo { + fn bar() { + Foo { baz: 0 }.bar(); + } + + fn bar() { //~ ERROR duplicate definition of value bar + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-4542.rs b/src/test/compile-fail/issue-4542.rs new file mode 100644 index 00000000000..6f41e516461 --- /dev/null +++ b/src/test/compile-fail/issue-4542.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test + +fn main() { + for os::args().each |arg| { + match copy *arg { + s => { } + } + } +} diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs new file mode 100644 index 00000000000..8a28fd17b1c --- /dev/null +++ b/src/test/compile-fail/issue-5035.rs @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +trait I {} +type K = I; +impl K for int {} +fn main() {} diff --git a/src/test/compile-fail/issue-5062.rs b/src/test/compile-fail/issue-5062.rs new file mode 100644 index 00000000000..a05463f31d3 --- /dev/null +++ b/src/test/compile-fail/issue-5062.rs @@ -0,0 +1,12 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +fn main() { fmt!("%?", None); } //~ ERROR can't resolve type variable diff --git a/src/test/compile-fail/issue-5099.rs b/src/test/compile-fail/issue-5099.rs new file mode 100644 index 00000000000..80720f9e863 --- /dev/null +++ b/src/test/compile-fail/issue-5099.rs @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait B < A > { fn a() -> A { self.a} } //~ ERROR unresolved name + +fn main() {} diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs new file mode 100644 index 00000000000..3df10cd00a9 --- /dev/null +++ b/src/test/run-pass/issue-3556.rs @@ -0,0 +1,42 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern mod std; +use core::io::WriterUtil; + +enum Token { + Text(@~str), + ETag(@~[~str], @~str), + UTag(@~[~str], @~str), + Section(@~[~str], bool, @~[Token], @~str, @~str, @~str, @~str, @~str), + IncompleteSection(@~[~str], bool, @~str, bool), + Partial(@~str, @~str, @~str), +} + +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; +} + +fn main() +{ + // fail_unless!(check_strs(fmt!("%?", Text(@~"foo")), "Text(@~\"foo\")")); + // fail_unless!(check_strs(fmt!("%?", ETag(@~[~"foo"], @~"bar")), "ETag(@~[ ~\"foo\" ], @~\"bar\")")); + + let t = Text(@~"foo"); + let u = Section(@~[~"alpha"], true, @~[t], @~"foo", @~"foo", @~"foo", @~"foo", @~"foo"); + let v = fmt!("%?", u); // this is the line that causes the seg fault + fail_unless!(v.len() > 0); +} diff --git a/src/test/run-pass/issue-3907-2.rs b/src/test/run-pass/issue-3907-2.rs new file mode 100644 index 00000000000..8599caa3306 --- /dev/null +++ b/src/test/run-pass/issue-3907-2.rs @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// aux-build:issue_3907_1.rs +extern mod issue_3907_1; + +type Foo = issue_3907_1::Foo; + +struct S { + name: int +} + +impl Foo for S { + fn bar() { } +} + +fn main() { + let s = S { + name: 0 + }; + s.bar(); +} diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs new file mode 100644 index 00000000000..d6531f30129 --- /dev/null +++ b/src/test/run-pass/issue-4241.rs @@ -0,0 +1,126 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern mod std; + +use std::net::tcp::TcpSocketBuf; + +use core::io::{ReaderUtil,WriterUtil}; + +enum Result { + Nil, + Int(int), + Data(~[u8]), + List(~[Result]), + Error(~str), + Status(~str) +} + +priv fn parse_data(len: uint, io: @io::Reader) -> Result { + let res = + if (len > 0) { + let bytes = io.read_bytes(len as uint); + fail_unless!(bytes.len() == len); + Data(bytes) + } else { + Data(~[]) + }; + fail_unless!(io.read_char() == '\r'); + fail_unless!(io.read_char() == '\n'); + return res; +} + +priv fn parse_list(len: uint, io: @io::Reader) -> Result { + let mut list: ~[Result] = ~[]; + for len.times { + let v = + match io.read_char() { + '$' => parse_bulk(io), + ':' => parse_int(io), + _ => fail!() + }; + list.push(v); + } + return List(list); +} + +priv fn chop(s: ~str) -> ~str { + s.slice(0, s.len() - 1).to_owned() +} + +priv fn parse_bulk(io: @io::Reader) -> Result { + match int::from_str(chop(io.read_line())) { + None => fail!(), + Some(-1) => Nil, + Some(len) if len >= 0 => parse_data(len as uint, io), + Some(_) => fail!() + } +} + +priv fn parse_multi(io: @io::Reader) -> Result { + match int::from_str(chop(io.read_line())) { + None => fail!(), + Some(-1) => Nil, + Some(0) => List(~[]), + Some(len) if len >= 0 => parse_list(len as uint, io), + Some(_) => fail!() + } +} + +priv fn parse_int(io: @io::Reader) -> Result { + match int::from_str(chop(io.read_line())) { + None => fail!(), + Some(i) => Int(i) + } +} + +priv fn parse_response(io: @io::Reader) -> Result { + match io.read_char() { + '$' => parse_bulk(io), + '*' => parse_multi(io), + '+' => Status(chop(io.read_line())), + '-' => Error(chop(io.read_line())), + ':' => parse_int(io), + _ => fail!() + } +} + +priv fn cmd_to_str(cmd: ~[~str]) -> ~str { + let mut res = ~"*"; + str::push_str(&mut res, cmd.len().to_str()); + str::push_str(&mut res, "\r\n"); + for cmd.each |s| { + str::push_str(&mut res, str::concat(~[~"$", s.len().to_str(), ~"\r\n", + copy *s, ~"\r\n"])); + } + res +} + +fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result { + let cmd = cmd_to_str(cmd); + //io::println(cmd); + sb.write_str(cmd); + let res = parse_response(@sb as @io::Reader); + //io::println(fmt!("%?", res)); + res +} + +fn query2(cmd: ~[~str]) -> Result { + let _cmd = cmd_to_str(cmd); + do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| { + let res = parse_response(@sb as @io::Reader); + io::println(fmt!("%?", res)); + res + } +} + + +fn main() { +} diff --git a/src/test/run-pass/issue-4252.rs b/src/test/run-pass/issue-4252.rs new file mode 100644 index 00000000000..f3b73c84714 --- /dev/null +++ b/src/test/run-pass/issue-4252.rs @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test + +trait X { + fn call(&self); +} + +struct Y; + +struct Z<T> { + x: T +} + +impl X for Y { + fn call(&self) { + } +} + +impl<T: X> Drop for Z<T> { + fn finalize(&self) { + self.x.call(); // Adding this statement causes an ICE. + } +} + +fn main() { + let y = Y; + let _z = Z{x: y}; +} \ No newline at end of file diff --git a/src/test/run-pass/issue-4387.rs b/src/test/run-pass/issue-4387.rs new file mode 100644 index 00000000000..8146a4e6b8c --- /dev/null +++ b/src/test/run-pass/issue-4387.rs @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let foo = [0, ..2*4]; +} diff --git a/src/test/run-pass/unconstrained-region.rs b/src/test/run-pass/unconstrained-region.rs new file mode 100644 index 00000000000..b6e2ba553df --- /dev/null +++ b/src/test/run-pass/unconstrained-region.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// xfail-test +// See #3283 +fn foo(blk: &fn(p: &'a fn() -> &'a fn())) { + let mut state = 0; + let statep = &mut state; + do blk { + || { *statep = 1; } + } +} +fn main() { + do foo |p| { p()() } +} \ No newline at end of file |
