()
| 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 | } |
nothing calls this directly
no test coverage detected