mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
fix(varcon): Catch bad Pos values
This commit is contained in:
parent
6ab147af94
commit
095c7aecc2
1 changed files with 8 additions and 66 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
use winnow::combinator::cut_err;
|
||||||
use winnow::combinator::delimited;
|
use winnow::combinator::delimited;
|
||||||
use winnow::combinator::trace;
|
use winnow::combinator::trace;
|
||||||
use winnow::prelude::*;
|
use winnow::prelude::*;
|
||||||
|
@ -995,7 +996,10 @@ impl Entry {
|
||||||
let (_abbr, _plural, pos, archaic, note, description) = (
|
let (_abbr, _plural, pos, archaic, note, description) = (
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "<abbr>")),
|
winnow::combinator::opt((winnow::ascii::space1, "<abbr>")),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "<pl>")),
|
winnow::combinator::opt((winnow::ascii::space1, "<pl>")),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, delimited('<', Pos::parse_, '>'))),
|
winnow::combinator::opt((
|
||||||
|
winnow::ascii::space1,
|
||||||
|
delimited('<', cut_err(Pos::parse_), cut_err('>')),
|
||||||
|
)),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "(-)")),
|
winnow::combinator::opt((winnow::ascii::space1, "(-)")),
|
||||||
winnow::combinator::opt((winnow::ascii::space1, "--")),
|
winnow::combinator::opt((winnow::ascii::space1, "--")),
|
||||||
winnow::combinator::opt((
|
winnow::combinator::opt((
|
||||||
|
@ -1237,72 +1241,10 @@ Entry {
|
||||||
fn test_pos_bad() {
|
fn test_pos_bad() {
|
||||||
// Having nothing after `A` causes an incomplete parse. Shouldn't be a problem for my use
|
// Having nothing after `A` causes an incomplete parse. Shouldn't be a problem for my use
|
||||||
// cases.
|
// cases.
|
||||||
let (input, actual) = Entry::parse_
|
let err = Entry::parse_
|
||||||
.parse_peek("A B C: practice / AV Cv: practise | <Bad>\n")
|
.parse_peek("A B C: practice / AV Cv: practise | <Bad>\n")
|
||||||
.unwrap();
|
.unwrap_err();
|
||||||
assert_data_eq!(
|
assert_data_eq!(err.to_string(), str!["Parsing Failure: ()"]);
|
||||||
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(
|
|
||||||
"<Bad>",
|
|
||||||
),
|
|
||||||
comment: None,
|
|
||||||
}
|
|
||||||
|
|
||||||
"#]]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue