Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
27
third-party/vendor/stacker/tests/simple.rs
vendored
Normal file
27
third-party/vendor/stacker/tests/simple.rs
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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, F: FnOnce() -> 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() {
|
||||
let limit = if cfg!(target_arch = "wasm32") {
|
||||
2000
|
||||
} else {
|
||||
10000
|
||||
};
|
||||
recurse(limit);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue