Skip to content

Commit

Permalink
Fix #126 - Simulator reset does not wait for simulation to complete (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuriakella authored Jun 14, 2022
1 parent ffa65c5 commit 26cb8df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/simulator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Simulator {
///
/// Note: values deposited on [Module]s from the previous simulation remain.
static Future<void> reset() async {
if (_simulationEndRequested) await simulationEnded;

_currentTimestamp = 0;
_simulationEndRequested = false;
_maxSimTime = -1;
Expand Down
7 changes: 7 additions & 0 deletions test/simulator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,11 @@ void main() {
expect(tooFar, equals(false));
expect(farEnough, equals(true));
});

test('simulator reset waits for simulation to complete', () async {
Simulator.registerAction(100, () => Simulator.endSimulation());
Simulator.registerAction(100, () => Simulator.reset());
Simulator.registerAction(100, () => true);
await Simulator.run();
});
}

0 comments on commit 26cb8df

Please sign in to comment.