#[macro_export]
macro_rules! math_consts_context {
() => {
$crate::math_consts_context!(
PI,
TAU,
FRAC_PI_2,
FRAC_PI_3,
FRAC_PI_4,
FRAC_PI_6,
FRAC_PI_8,
FRAC_1_PI,
FRAC_2_PI,
FRAC_2_SQRT_PI,
SQRT_2,
FRAC_1_SQRT_2,
E,
LOG2_10,
LOG2_E,
LOG10_2,
LOG10_E,
LN_2,
LN_10
)
};
($($name:ident),*) => {{
$crate::context_map! {
$(
stringify!($name) => float core::f64::consts::$name,
)*
}
}};
}
#[cfg(test)]
mod tests {
#[test]
fn math_consts_context() {
let context: crate::HashMapContext = math_consts_context!().unwrap();
{
use crate::{Context, Value};
assert_eq!(
context.get_value("PI"),
Some(&Value::Float(core::f64::consts::PI))
);
}
}
}