Add some tests for expression corner cases, mostly involving ret and fail
Some of these don't actually work.
This commit is contained in:
parent
d681f062c7
commit
664b0ad3fc
15
src/test/run-fail/fail-parens.rs
Normal file
15
src/test/run-fail/fail-parens.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// xfail-stage1
|
||||
// xfail-stage2
|
||||
// xfail-stage3
|
||||
// Fail statements without arguments need to be disambiguated in
|
||||
// certain positions
|
||||
// error-pattern:explicit-failure
|
||||
|
||||
fn bigfail() {
|
||||
do { while (fail) { if (fail) {
|
||||
alt (fail) { _ {
|
||||
}}
|
||||
}}} while fail;
|
||||
}
|
||||
|
||||
fn main() { bigfail(); }
|
85
src/test/run-pass/wierd-exprs.rs
Normal file
85
src/test/run-pass/wierd-exprs.rs
Normal file
@ -0,0 +1,85 @@
|
||||
// xfail-pretty
|
||||
// Just a grab bug of stuff that you wouldn't want to actualy write
|
||||
|
||||
fn strange() -> bool {
|
||||
let _x = ret true;
|
||||
}
|
||||
|
||||
fn funny() {
|
||||
fn f(_x: ()) {}
|
||||
f(ret);
|
||||
}
|
||||
|
||||
fn odd() {
|
||||
// FIXME: This doesn't compile
|
||||
// log ret;
|
||||
}
|
||||
|
||||
fn what() {
|
||||
fn the(x: @mutable bool){
|
||||
ret while !*x { *x = true };
|
||||
}
|
||||
let i = @mutable false;
|
||||
let dont = bind the(i);
|
||||
dont();
|
||||
assert *i;
|
||||
}
|
||||
|
||||
fn zombiejesus() {
|
||||
do { while (ret) { if (ret) {
|
||||
alt (ret) { _ {
|
||||
ret ? ret : ret
|
||||
}}
|
||||
}}} while ret;
|
||||
}
|
||||
|
||||
fn notsure() {
|
||||
let _x;
|
||||
let _y = (_x = 0) == (_x = 0);
|
||||
let _z = (_x <- 0) < (_x = 0);
|
||||
let _a = (_x += 0) == (_x = 0);
|
||||
let _b = (_y <-> _z) == (_y <-> _z);
|
||||
}
|
||||
|
||||
fn hammertime() -> int {
|
||||
// FIXME: Doesn't compile
|
||||
//let _x = log true == (ret 0);
|
||||
ret 0;
|
||||
}
|
||||
|
||||
fn canttouchthis() -> uint {
|
||||
pred p() -> bool { true }
|
||||
let _a = (assert true) == (check p());
|
||||
let _c = (check p()) == ();
|
||||
let _b = (log 0) == (ret 0u);
|
||||
}
|
||||
|
||||
fn angrydome() {
|
||||
while true {
|
||||
if (break) { }
|
||||
}
|
||||
let i = 0;
|
||||
do {
|
||||
i += 1;
|
||||
if i == 1 {
|
||||
alt cont { _ { } }
|
||||
}
|
||||
} while false;
|
||||
}
|
||||
|
||||
fn evil_lincoln() {
|
||||
let evil <- log "lincoln";
|
||||
}
|
||||
|
||||
fn main() {
|
||||
strange();
|
||||
funny();
|
||||
odd();
|
||||
what();
|
||||
zombiejesus();
|
||||
notsure();
|
||||
hammertime();
|
||||
canttouchthis();
|
||||
angrydome();
|
||||
evil_lincoln();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user