Inspect original primitives and unexpanded tokens
This commit is contained in:
1 parent
c094d9a81d
commit
2007ac5627
7 files changed
+147
-11
No files matched your search
@@ -85,3 +85,49 @@ fn condition_stack_traces_match_real_expansion_and_skipping() {
|
||||
}
|
||||
fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn primitive_inspection_requires_the_original_name_and_live_meaning() {
|
||||
for (profile, spelling) in [
|
||||
(InputProfile::TeX8Bit, r"\ifpdfprimitive"),
|
||||
(InputProfile::XeTeX, r"\ifprimitive"),
|
||||
] {
|
||||
let source = r"\catcode123=1 \catcode125=2 \catcode35=6
|
||||
\let\check=CHECK
|
||||
\let\saved=\hbox
|
||||
\def\query#1{\message{\check#1YES\else NO\fi}}
|
||||
\query\hbox \query\saved
|
||||
{\let\hbox=\vbox \query\hbox}
|
||||
\query\hbox
|
||||
\message{\expandafter\check\noexpand\iftrue YES\else NO\fi}
|
||||
\outer\def\outercommand{}
|
||||
\query\notdefined
|
||||
\message{\check\outercommand YES\else NO\fi}
|
||||
\def\kept{\errmessage{should not expand}}
|
||||
\def\opening{{\kept##A}}
|
||||
\showtokens\opening
|
||||
\end"
|
||||
.replace("CHECK", spelling);
|
||||
let result = Executor::new(
|
||||
State::initex().with_etex().with_input_profile(profile),
|
||||
Limits::default(),
|
||||
)
|
||||
.run(
|
||||
SourceFile {
|
||||
name: "inspect.tex".into(),
|
||||
data: source.into_bytes(),
|
||||
},
|
||||
&mut NoFiles,
|
||||
)
|
||||
.unwrap();
|
||||
let messages: Vec<_> = result.events.iter().filter_map(|event| match event {
|
||||
Event::Message { text, .. } => Some(text.as_str()),
|
||||
_ => None,
|
||||
}).collect();
|
||||
assert_eq!(messages, ["YES", "NO", "NO", "YES", "NO", "NO", "NO"]);
|
||||
assert!(result.events.iter().any(|event| matches!(
|
||||
event, Event::Show(report) if report.text.trim() == r"> \kept ##A."
|
||||
)));
|
||||
assert!(result.reads.contains(&Dependency::Meaning(CommandName::Control("hbox".into()))));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user