From 69d6e0d208137de067f7ee29d053be0ef4005c47 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 9 Sep 2011 16:20:11 -0700 Subject: [PATCH] Add some more unwind tests They worked without modifications, but I wrote them so we're keeping them. Issue #236 --- src/test/run-fail/unwind-lambda.rs | 16 ++++++++++++++++ src/test/run-fail/unwind-misc-1.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/test/run-fail/unwind-lambda.rs create mode 100644 src/test/run-fail/unwind-misc-1.rs diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs new file mode 100644 index 0000000000000..28907f3af9f52 --- /dev/null +++ b/src/test/run-fail/unwind-lambda.rs @@ -0,0 +1,16 @@ +// error-pattern:fail + +fn main() { + let cheese = "roquefort"; + let carrots = @"crunchy"; + + fn (tasties: @str, macerate: &block(&str)) { + macerate(*tasties); + } (carrots, { |&food| + let mush = food + cheese; + lambda() { + let chew = mush + cheese; + fail "so yummy" + } (); + }); +} \ No newline at end of file diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs new file mode 100644 index 0000000000000..0ae4302616a45 --- /dev/null +++ b/src/test/run-fail/unwind-misc-1.rs @@ -0,0 +1,28 @@ +// error-pattern:fail + +use std; +import std::map; +import std::uint; + +fn main() { + let count = @mutable 0u; + let hash = bind fn (_s: &[@str], count: @mutable uint) -> uint { + *count += 1u; + if *count == 10u { + fail; + } else { + ret *count; + } + } (_, count); + + fn eq(s: &[@str], t: &[@str]) -> bool { + ret s == t; + } + + let map = map::mk_hashmap(hash, eq); + let arr = []; + for each i in uint::range(0u, 10u) { + arr += [@"key stuff"]; + map.insert(arr, arr + [@"value stuff"]); + } +} \ No newline at end of file