From 26ab38f81c7e73127c14f63dcaff23f12e66d94a Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 16 Nov 2018 10:24:44 +0100 Subject: [PATCH] Add some integration tests --- tests/simple.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/simple.rs diff --git a/tests/simple.rs b/tests/simple.rs new file mode 100644 index 0000000..4e4c46f --- /dev/null +++ b/tests/simple.rs @@ -0,0 +1,24 @@ +extern crate stacker; + +const RED_ZONE: usize = 100*1024; // 100k +const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB + +pub fn ensure_sufficient_stack R + std::panic::UnwindSafe>( + f: F +) -> R { + stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f) +} + +#[inline(never)] +fn recurse(n: usize) { + let x = [42u8; 50000]; + if n != 0 { + ensure_sufficient_stack(|| recurse(n - 1)); + } + drop(x); +} + +#[test] +fn foo() { + recurse(10000); +} \ No newline at end of file