Skip to content

Commit

Permalink
add test for kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
grantlemons committed Oct 3, 2024
1 parent 4e6e356 commit e2c90a2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions harper-core/src/parsers/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,31 @@ mod tests {
assert_eq!(tokens.len(), 10);
}

#[test]
fn kebab_collapse() {
let source = "This is a separated-identifier, wow!";
let default_dict = FullDictionary::curated();

let tokens = Cases::new(
Box::new(PlainEnglish),
&Lrc::new(default_dict.clone().into()),
)
.parse_str(source);
assert_eq!(tokens.len(), 13);

let mut dict = FullDictionary::new();
dict.append_word(
"separated-identifier".chars().collect_vec(),
WordMetadata::default(),
);

let mut merged_dict = MergedDictionary::from(default_dict);
merged_dict.add_dictionary(Lrc::new(dict));

let tokens = Cases::new(Box::new(PlainEnglish), &Lrc::new(merged_dict)).parse_str(source);
assert_eq!(tokens.len(), 10);
}

#[test]
fn double_collapse() {
let source = "This is a separated_identifier_token, wow!";
Expand Down

0 comments on commit e2c90a2

Please # to comment.