Skip to content

Commit

Permalink
Delay init of replay so that arbitrary can be re-used
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Jan 27, 2019
1 parent 5a0d42d commit b2a3469
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/check/model/commands/CommandsArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class CommandsArbitrary<Model extends object, Real, RunResult, CheckAsync extend
constructor(
commandArbs: Arbitrary<ICommand<Model, Real, RunResult, CheckAsync>>[],
maxCommands: number,
replayPathStr: string | null,
readonly sourceReplayPath: string | null,
readonly disableReplayLog: boolean
) {
super();
this.oneCommandArb = oneof(...commandArbs).map(c => new CommandWrapper(c));
this.lengthArb = nat(maxCommands);
this.replayPath = replayPathStr !== null ? ReplayPath.parse(replayPathStr) : [];
this.replayPath = []; // updated at first shrink
this.replayPathPosition = 0;
}
private metadataForReplay() {
Expand All @@ -52,9 +52,13 @@ class CommandsArbitrary<Model extends object, Real, RunResult, CheckAsync extend
const item = this.oneCommandArb.generate(mrng);
items[idx] = item;
}
this.replayPathPosition = 0; // reset replay
return this.wrapper(items, false, false);
}
private filterNonExecuted(itemsRaw: Shrinkable<CommandWrapper<Model, Real, RunResult, CheckAsync>>[]) {
if (this.replayPathPosition === 0) {
this.replayPath = this.sourceReplayPath !== null ? ReplayPath.parse(this.sourceReplayPath) : [];
}
const items: typeof itemsRaw = [];
for (let idx = 0; idx !== itemsRaw.length; ++idx) {
const c = itemsRaw[idx];
Expand Down

0 comments on commit b2a3469

Please sign in to comment.