MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / test_execution_errors

Function test_execution_errors

cel/src/lib.rs:283–318  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

281
282 #[test]
283 fn test_execution_errors() {
284 let tests = vec![
285 (
286 "no such key",
287 "foo.baz.bar == 1",
288 ExecutionError::no_such_key("baz"),
289 ),
290 (
291 "undeclared reference",
292 "missing == 1",
293 ExecutionError::undeclared_reference("missing"),
294 ),
295 (
296 "undeclared method",
297 "1.missing()",
298 ExecutionError::undeclared_reference("missing"),
299 ),
300 (
301 "undeclared function",
302 "missing(1)",
303 ExecutionError::undeclared_reference("missing"),
304 ),
305 (
306 "unsupported key type",
307 "{null: true}",
308 ExecutionError::unsupported_key_type(Value::Null),
309 ),
310 ];
311
312 for (name, script, error) in tests {
313 let mut ctx = Context::default();
314 ctx.add_variable_from_value("foo", HashMap::from([("bar", 1)]));
315 let res = test_script(script, Some(ctx));
316 assert_eq!(res, error.into(), "{name}");
317 }
318 }
319}

Callers

nothing calls this directly

Calls 2

test_scriptFunction · 0.85

Tested by

no test coverage detected