Scan macro parameters using the current command meaning
This commit is contained in:
1 parent
2846f7f1e7
commit
ab6b1093ec
3 files changed
+126
-19
No files matched your search
@@ -80,3 +80,57 @@ fn macro_trace_follows_real_calls_and_parameters_in_each_channel() {
|
||||
assert_eq!(trace_lines(&native_log).len(), 9);
|
||||
fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn definition_scans_aliased_parameter_commands_and_keeps_literal_tokens() {
|
||||
let source = r"\catcode123=1 \catcode125=2 \catcode35=6 \catcode33=6
|
||||
\let\marker=#\let\alternate=!
|
||||
\protected\def\digit{1}
|
||||
\begingroup
|
||||
\catcode35=12 \catcode33=12
|
||||
\def\pair\marker1,\alternate2;{\marker1:\alternate2}
|
||||
\edef\expandedpair\marker1{\noexpand\marker\digit}
|
||||
\def\literal{\marker\alternate}
|
||||
\edef\saved{\unexpanded{\marker}}
|
||||
\def\braced\marker{[prefix]}
|
||||
\message{PAIR=(\pair left,right;)}
|
||||
\message{EDEF=(\expandedpair{expanded})}
|
||||
\message{LITERAL=(\meaning\literal)}
|
||||
\message{FROZEN=(\meaning\saved)}
|
||||
\message{BRACE=(\braced{argument})}
|
||||
\message{TEMPLATE=(\meaning\pair)}
|
||||
\endgroup
|
||||
\end";
|
||||
for profile in [InputProfile::TeX8Bit, InputProfile::XeTeX] {
|
||||
let state = State::initex().with_etex().with_input_profile(profile);
|
||||
let result = Executor::new(state, Limits::default())
|
||||
.run(
|
||||
SourceFile {
|
||||
name: "marker.tex".into(),
|
||||
data: source.as_bytes().into(),
|
||||
},
|
||||
&mut Host,
|
||||
)
|
||||
.unwrap();
|
||||
let messages = result
|
||||
.events
|
||||
.iter()
|
||||
.filter_map(|event| match event {
|
||||
Event::Message { text, .. } => Some(text.as_str()),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
messages,
|
||||
[
|
||||
"PAIR=(left:right)",
|
||||
"EDEF=(expanded)",
|
||||
r"LITERAL=(macro:->\alternate )",
|
||||
r"FROZEN=(macro:->\marker )",
|
||||
"BRACE=([prefix]{argument})",
|
||||
"TEMPLATE=(macro:#1,!2;->!1:!2)",
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user