Merge Instruction as many times as possible
This commit is contained in:
parent
d10b740545
commit
623bae7fc0
1 changed files with 18 additions and 15 deletions
|
|
@ -308,27 +308,30 @@ impl<P: Program + 'static> Tester<P> {
|
||||||
program.update(state, message).map(Tick::Program)
|
program.update(state, message).map(Tick::Program)
|
||||||
}
|
}
|
||||||
Tick::Recorder(event) => {
|
Tick::Recorder(event) => {
|
||||||
let Some(interaction) =
|
let mut interaction =
|
||||||
instruction::Interaction::from_event(event)
|
instruction::Interaction::from_event(event);
|
||||||
else {
|
|
||||||
return Task::none();
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(Instruction::Interact(last_interaction)) =
|
while let Some(new_interaction) = interaction.take() {
|
||||||
self.instructions.pop()
|
if let Some(Instruction::Interact(last_interaction)) =
|
||||||
{
|
self.instructions.pop()
|
||||||
let (last_interaction, new_interaction) =
|
{
|
||||||
last_interaction.merge(interaction);
|
let (merged_interaction, new_interaction) =
|
||||||
|
last_interaction.merge(new_interaction);
|
||||||
|
|
||||||
self.instructions
|
if let Some(new_interaction) = new_interaction {
|
||||||
.push(Instruction::Interact(last_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
|
self.instructions
|
||||||
.push(Instruction::Interact(new_interaction));
|
.push(Instruction::Interact(new_interaction));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
self.instructions.push(Instruction::Interact(interaction));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue