Merge Instruction as many times as possible

This commit is contained in:
Héctor Ramón Jiménez 2025-06-13 15:46:37 +02:00
parent d10b740545
commit 623bae7fc0
No known key found for this signature in database
GPG key ID: 4C07CEC81AFA161F

View file

@ -308,27 +308,30 @@ impl<P: Program + 'static> Tester<P> {
program.update(state, message).map(Tick::Program)
}
Tick::Recorder(event) => {
let Some(interaction) =
instruction::Interaction::from_event(event)
else {
return Task::none();
};
let mut interaction =
instruction::Interaction::from_event(event);
if let Some(Instruction::Interact(last_interaction)) =
self.instructions.pop()
{
let (last_interaction, new_interaction) =
last_interaction.merge(interaction);
while let Some(new_interaction) = interaction.take() {
if let Some(Instruction::Interact(last_interaction)) =
self.instructions.pop()
{
let (merged_interaction, new_interaction) =
last_interaction.merge(new_interaction);
self.instructions
.push(Instruction::Interact(last_interaction));
if let Some(new_interaction) = new_interaction {
self.instructions.push(Instruction::Interact(
merged_interaction,
));
if let Some(new_interaction) = new_interaction {
self.instructions
.push(Instruction::Interact(new_interaction));
} else {
interaction = Some(merged_interaction);
}
} else {
self.instructions
.push(Instruction::Interact(new_interaction));
}
} else {
self.instructions.push(Instruction::Interact(interaction));
}
Task::none()