| 4420 | } |
| 4421 | |
| 4422 | fn assert_parse_expr(input: &str, expr: Option<Expr>) { |
| 4423 | let result = parse_expr::<nom::error::VerboseError<&str>>(input); |
| 4424 | match result.clone() { |
| 4425 | Err(nom::Err::Error(e)) => trace!("Error: {}", nom::error::convert_error(input, e)), |
| 4426 | Err(nom::Err::Failure(e)) => trace!("Error: {}", nom::error::convert_error(input, e)), |
| 4427 | Err(nom::Err::Incomplete(e)) => unreachable!("Incomplete: {:?}", e), |
| 4428 | _ => {} |
| 4429 | } |
| 4430 | let result = result |
| 4431 | .map_err(|e| match e { |
| 4432 | nom::Err::Error(e) => nom::error::convert_error(input, e), |
| 4433 | nom::Err::Failure(e) => nom::error::convert_error(input, e), |
| 4434 | nom::Err::Incomplete(_) => unreachable!("Incomplete: {:?}", e), |
| 4435 | }) |
| 4436 | .unwrap(); |
| 4437 | trace!("{:?}", result); |
| 4438 | |
| 4439 | if let Some(expr) = expr { |
| 4440 | assert_eq!(result.1, expr); |
| 4441 | } |
| 4442 | } |
| 4443 | |
| 4444 | #[test] |
| 4445 | fn test_parse_const() { |