Skip to content

Commit

Permalink
tests added, needs docn
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Dec 8, 2024
1 parent c8244ba commit b2262b2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parser/src/cfg/zippychord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ fn parse_zippy_inner(
None => {
// note for unwrap below: must be list if not atom
let output_list = mapping_pair[1].list(s.vars()).unwrap();
if output_list.len() == 0 {
if output_list.is_empty() {
bail_expr!(
&mapping_pair[1],
"Empty list is invalid for zippy output mapping."
Expand Down
41 changes: 41 additions & 0 deletions src/tests/sim_tests/zippychord_sim_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,18 @@ const DEAD_KEYS_CFG: &str = "\
output-character-mappings (
’ (no-erase ')
‘ (no-erase `)
é (single-output ' e)
è (single-output ` e)
))";
static DEAD_KEYS_FILE_CONTENT: &str = "
by h’elo
bye by‘e
by d ft‘a’ng
by d a aye
cy hélo
cye byè
cy d ftéèng
cy d a aye
";

#[test]
Expand Down Expand Up @@ -687,3 +693,38 @@ fn sim_zippychord_noerase() {
result,
);
}

#[test]
fn sim_zippychord_single_output() {
let result = simulate_with_zippy_file_content(
DEAD_KEYS_CFG,
"d:c d:y t:100 d:e u:c u:y u:e t:1000",
DEAD_KEYS_FILE_CONTENT,
)
.no_releases()
.no_time()
.to_ascii();
assert_eq!(
"dn:C dn:BSpace dn:H dn:Quote dn:E dn:L dn:O dn:Space \
dn:BSpace dn:BSpace dn:BSpace dn:BSpace dn:BSpace \
dn:B dn:Y dn:Grave dn:E dn:Space",
result,
);

let result = simulate_with_zippy_file_content(
DEAD_KEYS_CFG,
"d:c d:y t:100 u:c u:y d:d t:10 u:d d:a t:10 u:a t:1000",
DEAD_KEYS_FILE_CONTENT,
)
.no_releases()
.no_time()
.to_ascii();
assert_eq!(
"dn:C dn:BSpace dn:H dn:Quote dn:E dn:L dn:O dn:Space \
dn:BSpace dn:BSpace dn:BSpace dn:BSpace dn:BSpace \
dn:F dn:T dn:Quote dn:E dn:Grave dn:E dn:N dn:G dn:Space \
dn:BSpace dn:BSpace dn:BSpace dn:BSpace dn:BSpace dn:BSpace dn:BSpace \
dn:A dn:Y dn:E dn:Space",
result,
);
}

0 comments on commit b2262b2

Please sign in to comment.