Skip to content

Commit 69d6e0d

Browse files
committed
Add some more unwind tests
They worked without modifications, but I wrote them so we're keeping them. Issue #236
1 parent e193c9c commit 69d6e0d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/test/run-fail/unwind-lambda.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// error-pattern:fail
2+
3+
fn main() {
4+
let cheese = "roquefort";
5+
let carrots = @"crunchy";
6+
7+
fn (tasties: @str, macerate: &block(&str)) {
8+
macerate(*tasties);
9+
} (carrots, { |&food|
10+
let mush = food + cheese;
11+
lambda() {
12+
let chew = mush + cheese;
13+
fail "so yummy"
14+
} ();
15+
});
16+
}

src/test/run-fail/unwind-misc-1.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// error-pattern:fail
2+
3+
use std;
4+
import std::map;
5+
import std::uint;
6+
7+
fn main() {
8+
let count = @mutable 0u;
9+
let hash = bind fn (_s: &[@str], count: @mutable uint) -> uint {
10+
*count += 1u;
11+
if *count == 10u {
12+
fail;
13+
} else {
14+
ret *count;
15+
}
16+
} (_, count);
17+
18+
fn eq(s: &[@str], t: &[@str]) -> bool {
19+
ret s == t;
20+
}
21+
22+
let map = map::mk_hashmap(hash, eq);
23+
let arr = [];
24+
for each i in uint::range(0u, 10u) {
25+
arr += [@"key stuff"];
26+
map.insert(arr, arr + [@"value stuff"]);
27+
}
28+
}

0 commit comments

Comments
 (0)