diff --git a/src/context/mod.rs b/src/context/mod.rs index dea9837..c135b5e 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -419,12 +419,12 @@ macro_rules! context_map { }}; // add an integer value, and chain the eventual error with the ones in the next values ( ($ctx:expr) $k:expr => int $v:expr , $($tt:tt)*) => {{ - $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), Value::from_int($v.into())) + $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), $crate::Value::from_int($v.into())) .and($crate::context_map!(($ctx) $($tt)*)) }}; // add a float value, and chain the eventual error with the ones in the next values ( ($ctx:expr) $k:expr => float $v:expr , $($tt:tt)*) => {{ - $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), Value::from_float($v.into())) + $crate::ContextWithMutableVariables::set_value($ctx, $k.into(), $crate::Value::from_float($v.into())) .and($crate::context_map!(($ctx) $($tt)*)) }}; // add a value, and chain the eventual error with the ones in the next values diff --git a/src/context/predefined/mod.rs b/src/context/predefined/mod.rs index ad8e785..3d15e5d 100644 --- a/src/context/predefined/mod.rs +++ b/src/context/predefined/mod.rs @@ -28,11 +28,28 @@ macro_rules! math_consts_context { ) }; ($($name:ident),*) => {{ - use $crate::ContextWithMutableVariables; $crate::context_map! { $( - stringify!($name) => core::f64::consts::$name, + 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)) + ); + } + } +}