Add a run-fail test for result::get, get rid of a FIXME. Also some random other tests, mostly xfailed.

This commit is contained in:
Tim Chevalier 2012-04-12 20:24:07 -07:00
parent 79e572ebbb
commit ea0063788b
8 changed files with 113 additions and 1 deletions

View File

@ -21,7 +21,6 @@ pure fn get<T: copy, U>(res: result<T, U>) -> T {
alt res {
ok(t) { t }
err(the_err) {
// FIXME: have a run-fail test for this
unchecked{ fail #fmt("get called on error result: %?", the_err); }
}
}

View File

@ -0,0 +1,23 @@
// xfail-test
type T = { mut f: fn@() };
type S = { f: fn@() };
fn fooS(t: S) {
}
fn fooT(t: T) {
}
fn bar() {
}
fn main() {
let x: fn@() = bar;
fooS({f: x});
fooS({f: bar});
let x: fn@() = bar;
fooT({mut f: x});
fooT({mut f: bar});
}

View File

@ -0,0 +1,11 @@
// xfail-test
fn main() {
let f = 42;
let _g = if f < 5 {
f.honk();
}
else {
12
};
}

View File

@ -0,0 +1,4 @@
// error-pattern:get called on error result: "kitty"
fn main() {
log(error, result::get(result::err("kitty")));
}

View File

@ -0,0 +1,3 @@
fn main() {
let _x = @{a: @10, b: ~true};
}

View File

@ -0,0 +1,3 @@
// xfail-test
fn main() { let early_error: fn@(str) -> ! = {|msg| fail }; }

View File

@ -0,0 +1,16 @@
// xfail-test
mod a {
type rust_task = uint;
native mod rustrt {
fn rust_task_is_unwinding(rt: *rust_task) -> bool;
}
}
mod b {
type rust_task = bool;
native mod rustrt {
fn rust_task_is_unwinding(rt: *rust_task) -> bool;
}
}
fn main() { }

View File

@ -0,0 +1,53 @@
// xfail-test
// fails pretty printing for some reason
use rustc;
import rustc::driver::diagnostic;
import rustc::syntax;
import rustc::syntax::ast;
import rustc::syntax::codemap;
import rustc::syntax::print::pprust;
import rustc::syntax::parse::parser;
fn new_parse_sess() -> parser::parse_sess {
let cm = codemap::new_codemap();
let handler = diagnostic::mk_handler(option::none);
let sess = @{
cm: cm,
mut next_id: 1,
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
mut chpos: 0u,
mut byte_pos: 0u
};
ret sess;
}
iface fake_ext_ctxt {
fn session() -> fake_session;
fn cfg() -> ast::crate_cfg;
fn parse_sess() -> parser::parse_sess;
}
type fake_options = {cfg: ast::crate_cfg};
type fake_session = {opts: @fake_options,
parse_sess: parser::parse_sess};
impl of fake_ext_ctxt for fake_session {
fn session() -> fake_session {self}
fn cfg() -> ast::crate_cfg { self.opts.cfg }
fn parse_sess() -> parser::parse_sess { self.parse_sess }
}
fn mk_ctxt() -> fake_ext_ctxt {
let opts : fake_options = {cfg: []};
{opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
}
fn main() {
let ext_cx = mk_ctxt();
let s = #ast(expr){__s};
let e = #ast(expr){__e};
let f = #ast(expr){$(s).foo {|__e| $(e)}};
log(error, pprust::expr_to_str(f));
}