use crate::error::Result;
use crate::modules::{Env, Fs, Glob, Hash, Hook, Json, ModuleSet, Path, Proc, Regex, Stdio, Time};
pub fn stdlib() -> Result<ModuleSet> {
let mut set = ModuleSet::new();
set.insert(Box::new(Json::new()))?;
set.insert(Box::new(Path::new()))?;
set.insert(Box::new(Fs::new()))?;
set.insert(Box::new(Env::new()))?;
set.insert(Box::new(Proc::new()))?;
set.insert(Box::new(Regex::new()))?;
set.insert(Box::new(Hash::new()))?;
set.insert(Box::new(Time::new()))?;
set.insert(Box::new(Glob::new()))?;
set.insert(Box::new(Stdio::new()))?;
set.insert(Box::new(Hook::new()))?;
Ok(set)
}
#[cfg(test)]
mod tests {
#![expect(
clippy::unwrap_used,
reason = "tests unwrap known-valid fixtures; a panic is the intended failure signal"
)]
use super::stdlib;
#[test]
fn the_default_set_builds_without_a_name_collision() {
assert!(stdlib().is_ok());
}
#[test]
fn the_default_set_includes_json() {
let set = stdlib().unwrap();
let names: Vec<_> = set.names().iter().map(ToString::to_string).collect();
assert!(names.contains(&String::from("json")), "{names:?}");
}
#[test]
fn the_default_set_is_not_empty() {
assert!(!stdlib().unwrap().is_empty());
}
}