Skip to content

Commit

Permalink
Fix: Unable to shrink mapped command
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Dec 15, 2018
1 parent f9f6f41 commit 21864f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/check/model/commands/CommandsArbitrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CommandsArbitrary<Model extends object, Real, RunResult> extends Arbitrary
return emptyOrNil
.join(size.shrink().map(l => items.slice(0, l.value).concat(items[items.length - 1]))) // try: remove items except the last one
.join(this.shrinkImpl(items.slice(0, items.length - 1), false).map(vs => vs.concat(items[items.length - 1]))) // try: keep last, shrink remaining (rec)
.join(items[0].shrink().map(v => [v].concat(items.slice(1)))); // try: shrink first, keep others
.join(items[items.length - 1].shrink().map(v => items.slice(0, -1).concat([v]))); // try: shrink last, keep others
}
}

Expand Down
8 changes: 1 addition & 7 deletions test/e2e/model/CommandsArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ describe(`CommandsArbitrary (seed: ${seed})`, () => {
const cmdsRepr = out.counterexample![0].toString();
const m = /check\[(\d+)\]$/.exec(cmdsRepr);
assert.notEqual(m, null, `Expected to end by a check[..] command, got: ${cmdsRepr}`);

const limit = +m![1];
const expectedRepr = `${[...Array(limit)].map(_ => 'inc').join(',')},check[${limit}]`;
assert.equal(cmdsRepr, expectedRepr);

// TODO: Use this expect instead
// assert.equal(cmdsRepr, 'inc,check[1]', `Expected the only played command to be 'inc,check[1]', got: ${cmdsRepr}`);
assert.equal(cmdsRepr, 'inc,check[1]', `Expected the only played command to be 'inc,check[1]', got: ${cmdsRepr}`);
});
it('Should result in empty commands if failures happen after the run', () => {
const out = fc.check(
Expand Down

0 comments on commit 21864f3

Please sign in to comment.