From 198f9d80e519b7b6a2d0360ed4ac8d9a612a22ed Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 23 Aug 2024 09:37:25 -0500 Subject: [PATCH] test(varcon): Show bad Pos parsing --- crates/varcon-core/src/parser.rs | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/crates/varcon-core/src/parser.rs b/crates/varcon-core/src/parser.rs index 9ca2d52..5768606 100644 --- a/crates/varcon-core/src/parser.rs +++ b/crates/varcon-core/src/parser.rs @@ -1227,6 +1227,78 @@ Entry { comment: None, } +"#]] + ); + } + + #[test] + fn test_pos_bad() { + // Having nothing after `A` causes an incomplete parse. Shouldn't be a problem for my use + // cases. + let (input, actual) = Entry::parse_ + .parse_peek("A B C: practice / AV Cv: practise | \n") + .unwrap(); + assert_data_eq!( + input, + str![[r#" + + +"#]] + ); + assert_data_eq!( + actual.to_debug(), + str![[r#" +Entry { + variants: [ + Variant { + types: [ + Type { + category: American, + tag: None, + num: None, + }, + Type { + category: BritishIse, + tag: None, + num: None, + }, + Type { + category: Canadian, + tag: None, + num: None, + }, + ], + word: "practice", + }, + Variant { + types: [ + Type { + category: American, + tag: Some( + Seldom, + ), + num: None, + }, + Type { + category: Canadian, + tag: Some( + Variant, + ), + num: None, + }, + ], + word: "practise", + }, + ], + pos: None, + archaic: false, + note: false, + description: Some( + "", + ), + comment: None, +} + "#]] ); }