artichoke_backend/extn/stdlib/monitor/
mod.rs

1use std::ffi::CStr;
2
3use crate::extn::prelude::*;
4
5const MONITOR_CSTR: &CStr = c"Monitor";
6static MONITOR_RUBY_SOURCE: &[u8] = include_bytes!("vendor/monitor.rb");
7
8pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
9    let spec = class::Spec::new("Monitor", MONITOR_CSTR, None, None)?;
10    interp.def_class::<Monitor>(spec)?;
11    interp.def_rb_source_file("monitor.rb", MONITOR_RUBY_SOURCE)?;
12
13    Ok(())
14}
15
16#[derive(Debug, Clone, Copy)]
17pub struct Monitor;
18
19#[cfg(test)]
20mod tests {
21    use crate::test::prelude::*;
22
23    const SUBJECT: &str = "Monitor";
24    const FUNCTIONAL_TEST: &[u8] = include_bytes!("monitor_test.rb");
25
26    #[test]
27    fn functional() {
28        let mut interp = interpreter();
29        let result = interp.eval(FUNCTIONAL_TEST);
30        unwrap_or_panic_with_backtrace(&mut interp, SUBJECT, result);
31        let result = interp.eval(b"spec");
32        unwrap_or_panic_with_backtrace(&mut interp, SUBJECT, result);
33    }
34}