#![cfg_attr(nightly, feature(alloc_error_hook))]
#[rustversion::nightly]
#[test]
#[serial_test::serial]
#[should_panic(expected = "OOM")]
fn oom() {
use stumpalo::Arena;
use std::alloc::{Layout, set_alloc_error_hook, take_alloc_error_hook};
fn oom_handler(_: Layout) {
panic!("OOM")
}
let old = take_alloc_error_hook();
set_alloc_error_hook(oom_handler);
let arena = Arena::new();
let huge_len = isize::MAX as usize / 2;
let _: &mut [u8] = arena.alloc_slice_fill_with(huge_len, |_| 0u8);
set_alloc_error_hook(old);
}