Skip to content

Commit b56e244

Browse files
⚡ Bolt: fix test coverage regressions in Context map lookups
Co-authored-by: ashyanSpada <22587148+ashyanSpada@users.noreply.github.com>
1 parent 0eecb8c commit b56e244

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/context.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,31 @@ macro_rules! create_context {
9898
ctx
9999
}};
100100
}
101+
102+
#[cfg(test)]
103+
mod tests {
104+
use super::*;
105+
use crate::value::Value;
106+
107+
#[test]
108+
fn test_context_methods() {
109+
let mut ctx = Context::new();
110+
ctx.set_variable("var1", Value::from(42));
111+
ctx.set_func("func1", Arc::new(|_| Ok(Value::from(100))));
112+
113+
// Test get_variable
114+
assert_eq!(ctx.get_variable("var1").unwrap(), Value::from(42));
115+
assert!(ctx.get_variable("func1").is_none());
116+
assert!(ctx.get_variable("not_found").is_none());
117+
118+
// Test get_func
119+
assert!(ctx.get_func("func1").is_some());
120+
assert!(ctx.get_func("var1").is_none());
121+
assert!(ctx.get_func("not_found").is_none());
122+
123+
// Test value
124+
assert_eq!(ctx.value("var1").unwrap(), Value::from(42));
125+
assert_eq!(ctx.value("func1").unwrap(), Value::from(100));
126+
assert_eq!(ctx.value("not_found").unwrap(), Value::None);
127+
}
128+
}

0 commit comments

Comments
 (0)