#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;

use std::sync::Arc;

use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::Term;

use crate::erlang::start_timer;
use crate::runtime::timer::Format;

#[native_implemented::function(erlang:start_timer/3)]
pub fn result(
    arc_process: Arc<Process>,
    time: Term,
    destination: Term,
    message: Term,
) -> exception::Result<Term> {
    start_timer(
        time,
        destination,
        Format::TimeoutTuple,
        message,
        Default::default(),
        arc_process,
    )
    .map_err(From::from)
}
