Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Mutator suggestion: modify constants #35

Open
Masterxilo opened this issue May 22, 2020 · 0 comments
Open

Mutator suggestion: modify constants #35

Masterxilo opened this issue May 22, 2020 · 0 comments

Comments

@Masterxilo
Copy link

There should be a mutator that replaces numeric constants. I imagine the following variants:

  • constant 0
  • constant 1
  • subtract/add 1

this should catch some off-by-one errors.

Example: It would detect that the following function:

export function lessThan100(x: number): boolean {
  if (x < 100) {
    return true;
  }
  return false;
}

Is not appropriately tested by the following testcases:

describe('lessThan100', () => {
  it('should detect which numbers are less than 100', () => {
    expect(lessThan100(100)).toEqual(false);
    expect(lessThan100(98)).toEqual(true);
  });
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant