pub(crate) struct TemplateFlowController {
pub(crate) stop_processing: bool,
pub(crate) processor_template_handler_pending: bool,
}
impl TemplateFlowController {
pub(crate) const fn new() -> Self {
Self {
stop_processing: false,
processor_template_handler_pending: false,
}
}
}
#[cfg(test)]
mod tests {
use std::fmt::Write;
use super::TemplateFlowController;
const JAVA_BASELINE: &str = "10f9dd2eb8cbd98515ce14b149d115e0287d0add";
const JAVA_GOLDEN: &str =
include_str!("../../tests/fixtures/template_flow_controller_golden.txt");
#[test]
fn defaults_and_independent_package_state_match_java_golden() {
let mut output = String::new();
emit(&mut output, "baseline", JAVA_BASELINE);
let mut first = TemplateFlowController::new();
let second = TemplateFlowController::new();
emit(
&mut output,
"default.first",
format!(
"{},{}",
first.stop_processing, first.processor_template_handler_pending
),
);
emit(
&mut output,
"default.second",
format!(
"{},{}",
second.stop_processing, second.processor_template_handler_pending
),
);
first.stop_processing = true;
emit(
&mut output,
"mutate.stop",
format!(
"{},{}",
first.stop_processing, first.processor_template_handler_pending
),
);
first.processor_template_handler_pending = true;
emit(
&mut output,
"mutate.pending",
format!(
"{},{}",
first.stop_processing, first.processor_template_handler_pending
),
);
emit(
&mut output,
"independent.second",
format!(
"{},{}",
second.stop_processing, second.processor_template_handler_pending
),
);
assert_eq!(output, JAVA_GOLDEN);
}
fn emit(output: &mut String, key: &str, value: impl std::fmt::Display) {
writeln!(output, "{key}={value}").expect("write to string");
}
}