Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions compose-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use {
thiserror::Error,
};

// const SINGLE: Option<&str> = Some("t0019");
// const SINGLE: Option<&str> = Some("t0054");
const SINGLE: Option<&str> = None;
const WRITE_MISSING: bool = true;
const WRITE_FAILED: bool = false;
Expand Down Expand Up @@ -76,6 +76,8 @@ enum ResultError {
WriteActualFailed(#[source] io::Error),
#[error("could not create compose table")]
CreateComposeTable,
#[error("unknown modifier `{0}`")]
UnknownModifier(String),
}

fn test_case2(diagnostics: &mut Vec<Diagnostic>, case: &Path) -> Result<(), ResultError> {
Expand Down Expand Up @@ -115,16 +117,32 @@ fn test_case2(diagnostics: &mut Vec<Diagnostic>, case: &Path) -> Result<(), Resu
if let Some((pre, _)) = line.split_once("#") {
line = pre;
}
line = line.trim();
if line.is_empty() {
continue;
let mut iter = line.split_whitespace();
match iter.next() {
Some(l) => line = l,
_ => continue,
}
let mut accept = None;
for modifier in iter {
match modifier {
"use" => accept = Some(true),
"skip" => accept = Some(false),
_ => return Err(ResultError::UnknownModifier(modifier.to_string())),
}
}
let Some(keysym) = Keysym::from_str(line) else {
return Err(ResultError::UnknownKeysym(line.to_string()));
};
let Some(res) = table.feed(&mut state, keysym) else {
let Some(mut out) = table.feed2(&mut state, keysym) else {
continue;
};
if let Some(accept) = accept {
match accept {
true => out.use_intermediate_composed(),
false => out.skip_intermediate_composed(),
}
}
let res = out.apply();
match res {
FeedResult::Pending => actual.push_str(" pending\n"),
FeedResult::Aborted => actual.push_str(" aborted\n"),
Expand Down
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0050/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a> <a>: A
<a>: B
<a> <a> <a>: C
7 changes: 7 additions & 0 deletions compose-tests/testcases/t00/t005/t0050/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a
pending
a
pending
a
composed
C
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0050/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a
a
a
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0051/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a> <a>: A
<a> <a> <a>: C
<a>: B
7 changes: 7 additions & 0 deletions compose-tests/testcases/t00/t005/t0051/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a skip
pending
a
pending
a
composed
C
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0051/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a skip
a
a
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0052/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a> <a> <a>: C
<a> <a>: A
<a>: B
9 changes: 9 additions & 0 deletions compose-tests/testcases/t00/t005/t0052/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
a
composed
B

a skip
pending
a
composed
A
4 changes: 4 additions & 0 deletions compose-tests/testcases/t00/t005/t0052/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a

a skip
a
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0053/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a>: B
<a> <a>: A
<a> <a> <a>: C
5 changes: 5 additions & 0 deletions compose-tests/testcases/t00/t005/t0053/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a
pending
a use
composed
A
2 changes: 2 additions & 0 deletions compose-tests/testcases/t00/t005/t0053/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a
a use
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0054/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a> <a> <a>: C
<a> <a>: A
<a>: B
6 changes: 6 additions & 0 deletions compose-tests/testcases/t00/t005/t0054/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a
composed
B
a
composed
B
2 changes: 2 additions & 0 deletions compose-tests/testcases/t00/t005/t0054/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a
a
1 change: 1 addition & 0 deletions compose-tests/testcases/t00/t005/t0055/XCompose
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a>: X
3 changes: 3 additions & 0 deletions compose-tests/testcases/t00/t005/t0055/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a skip
composed
X
1 change: 1 addition & 0 deletions compose-tests/testcases/t00/t005/t0055/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a skip
6 changes: 5 additions & 1 deletion kbvm/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- Added support for `VoidAction()`. This is an alias for
`LockControls(controls=none, affect=neither)`.
- In compose files, later productions now always override earlier productions.
That is, all of the following are the same:
That is, all of the following are the same in the `ComposeTable::feed` API.

```compose
<a> <b>: X
Expand All @@ -90,6 +90,10 @@
<a> <b> <c>: Y
<a> <b>: X
```
- A new function `ComposeTable::feed2` has been added to give more control over
situations such as the above. In the last example above, after inputting
`<a> <b>`, the application can choose to either use the `X` output or proceed
to the next possible sequence.

# 0.1.4 (2025-04-21)

Expand Down
Loading