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

26 lines
552 B
Rust
Raw Normal View History

// error-pattern:fail
use std;
import std::map;
import std::map::hashmap;
import uint;
fn main() {
2012-03-26 20:35:18 -05:00
let count = @mut 0u;
fn hash(&&s: [@str]/~) -> uint {
if (vec::len(s) > 0u && str::eq(*s[0], "boom")) { fail; }
ret 10u;
}
fn eq(&&s: [@str]/~, &&t: [@str]/~) -> bool {
ret s == t;
}
let map = map::hashmap(hash, eq);
let mut arr = []/~;
for uint::range(0u, 10u) {|i|
arr += [@"key stuff"]/~;
map.insert(arr, arr + [@"value stuff"]/~);
}
map.insert([@"boom"]/~, []/~);
}