Persist language-specific e-TeX hyphenation codes

This commit is contained in:
gloamxun committed 2026-11-28 12:14:12 +08:00
1 parent 11fd66713b
commit b472f66d04
10 files changed
+198 -45

No files matched your search

@@ -81,6 +81,51 @@ fn legal_dump_loads_owned_format_state_into_a_new_job() {
assert!(ordinary.message.contains("INITEX"));
}
#[test]
fn saved_hyphenation_codes_survive_groups_and_format_reload() {
let seed = r"\catcode123=1 \catcode125=2
\let\save=\savinghyphcodes
{\save=1 \language=0 \patterns{a1b}}
\language=1 \patterns{a1b}
{\save=1 \language=2 \lccode97=0 \patterns{}}
\lccode97=0 \dump";
let state = State::initex().with_etex();
let early = seed.replace(r"\dump", r"\language=0 \hyphenation{a-ba}\end");
let error = Executor::new(state.clone(), Limits::default())
.run(source("seed.tex", &early), &mut Host)
.unwrap_err();
assert!(error.message.contains("nonzero lccode"));
let dump = Executor::new(state.clone(), Limits::default())
.run(source("seed.tex", seed), &mut Host)
.unwrap();
let image = FormatImage::from_dump(dump, Vec::new(), Vec::new())
.unwrap()
.encode()
.unwrap();
let run = |text| {
FormatImage::decode(&image)
.unwrap()
.new_job(
state.profile(),
state.input_profile(),
JobTime::new(2026, 1, 2, 0).unwrap(),
Limits::default(),
|_| Ok(seed.as_bytes().to_vec()),
)
.unwrap()
.run(source("document.tex", text), &mut Host)
};
let job = run(r"\language=0 \hyphenation{a-ba}\message{\the\lccode97/\the\save}\end").unwrap();
assert!(job.events.iter().any(
|event| matches!(event, Event::Message { text, .. } if text == "0/0")
));
let error = run(r"\language=1 \hyphenation{a-ba}\end").unwrap_err();
assert!(error.message.contains("nonzero lccode"));
let error = run(r"\language=2 \lccode97=97 \hyphenation{a-ba}\end").unwrap_err();
assert!(error.message.contains("nonzero lccode"));
}
#[test]
fn format_stream_ranges_are_verified_against_one_read_per_path() {
use sha2::{Digest, Sha256};