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

Commit

Permalink
Align categories of mutators (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-vrijswijk committed Dec 4, 2018
1 parent 2449774 commit 5b5eb82
Showing 1 changed file with 168 additions and 130 deletions.
298 changes: 168 additions & 130 deletions mutator-types.md
Original file line number Diff line number Diff line change
@@ -1,183 +1,221 @@
# Supported mutators

Stryker supports a variety of mutators, which are listed below.
All Stryker versions support a variety of different mutators. The difference in support is listed below.

## Support

| Mutator | [Stryker](stryker/) | [Stryker.NET](stryker.net/) | [Stryker4s](stryker4s/) |
| - | :-: | :-: | :-: |
| [Binary Operators](#binary-operators) ||| ℹ️¹ |
| [Boolean Substitutions](#boolean-substitutions) ||| ℹ️² |
| [Logical operators](#logical-operators) ||||
| [Unary operators](#unary-operators) ||||
| [Update operators](#update-operators) ||| n/a |
| [Remove conditionals](#remove-conditionals) ||||
| [Assignment mutator](#assignment-mutator) ||| n/a |
| [Array declarator](#array-declarator) ||||
| [String mutator](#string-mutator) ||||
| [Block statement](#block-statement) ||||
| [Checked mutator](#checked-mutator) | n/a || n/a |
| [Method mutator](#method-mutator) | n/a |||

- ¹: Stryker4s does not support (`+`,`-`,`*`,`/` and `%` operators)
- ²: Stryker4s does not support boolean substitutions with `!`

## Binary operators

Original | Mutated
| - | - |
`a + b` | `a - b`
`a - b` | `a + b`
`a * b` | `a / b`
`a / b` | `a * b`
`a % b` | `a * b`
`a < b` | `a <= b`
`a < b` | `a >= b`
`a <= b` | `a < b`
`a <= b` | `a > b`
`a > b` | `a >= b`
`a > b` | `a <= b`
`a >= b` | `a > b`
`a >= b` | `a < b`
`a == b` | `a != b`
`a != b` | `a == b`
`a === b` | `a !== b`
`a !== b` | `a === b`
| Mutator | [Stryker](stryker/) | [Stryker.NET](stryker.net/) | [Stryker4s](stryker4s/) |
| ------------------------------------------------- | :-----------------: | :-------------------------: | :---------------------: |
| [Arithmetic Operator](#arithmetic-operator) ||||
| [Array Declaration](#array-declaration) ||||
| [Assignment Expression](#assignment-expression) ||| n/a |
| [Block Statement](#block-statement) ||||
| [Boolean Literal](#boolean-literal) ||| ️✅¹ |
| [Checked Statement](#checked-statement) | n/a || n/a |
| [Conditional Expression](#conditional-expression) ||||
| [Equality Operator](#equality-operator) ||||
| [Logical Operator](#logical-operator) ||||
| [Method Expression](#method-expression) ||||
| [String Literal](#string-literal) ||||
| [Unary Operator](#unary-operator) ||||
| [Update Operator](#update-operator) ||| n/a |

- ¹: Stryker4s does not support `!` boolean substitutions

## Arithmetic Operator

| Original | Mutated |
| -------- | ------- |
| `a + b` | `a - b` |
| `a - b` | `a + b` |
| `a * b` | `a / b` |
| `a / b` | `a * b` |
| `a % b` | `a * b` |

[🔝 Back to Top](#supported-mutators)

## Boolean Substitutions
## Array Declaration

Original | Mutated
| - | - |
`true` | `false`
`false` | `true`
`!` | ` `
| Original | Mutated |
| ----------------------- | ------------- |
| `new Array(1, 2, 3, 4)` | `new Array()` |
| `[1, 2, 3, 4]` | `[ ]` |

[🔝 Back to Top](#supported-mutators)

## Logical operators
## Assignment Expression

Original | Mutated
| - | - |
`a && b` | `a \|\| b` |
`a \|\| b` | `a && b` |
| Original | Mutated |
| -------- | ------- |
| `+=` | `-=` |
| `-=` | `+=` |
| `*=` | `/=` |
| `/=` | `*=` |
| `%=` | `*=` |
| `<<=` | `>>=` |
| `>>=` | `<<=` |
| `&=` | `\|=` |
| `\|=` | `&=` |

[🔝 Back to Top](#supported-mutators)

## Unary operators
## Block Statement

Original | Mutated
| - | - |
`+a` | `-a`
`-a` | `+a`
Removes the content of every block statement. For example the code:

[🔝 Back to Top](#supported-mutators)
```javascript
function saySomething() {
console.log('Hello world!');
}
```

## Update operators
becomes:

Original | Mutated
| - | - |
`a++` | `a--`
`a--` | `a++`
`++a` | `--a`
`--a` | `++a`
```javascript
function saySomething() {
}
```

[🔝 Back to Top](#supported-mutators)

## Remove conditionals
## Boolean Literal

Original | Mutated
| - | - |
`for (var i = 0; i < 10; i++) { }` | `for (var i = 0; false; i++) { }`
`while (a > b) { }` | `while (false) { }`
`do { } while (a > b);` | `do { } while (false);`
`if (a > b) { }` | `if (true) { }`
`if (a > b) { }` | `if (false) { }`
`var x = a > b ? 1 : 2;` | `var x = true ? 1 : 2;`
`var x = a > b ? 1 : 2;` | `var x = false ? 1 : 2;`
| Original | Mutated |
| ----------- | -------- |
| `true` | `false` |
| `false` | `true` |
| `!(a == b)` | `a == b` |

[🔝 Back to Top](#supported-mutators)

## Assignment mutator
## Checked Statement

Original | Mutated
| - | - |
`+=` | `-=`
`-=` | `+=`
`*=` | `/=`
`/=` | `*=`
`%=` | `*=`
`<<=` | `>>=`
`>>=`| `<<=`
`&=` | `\|=`
`\|=` | `&=`
Stryker.NET *specific mutator*

| Original | Mutated |
| ---------------- | ------- |
| `checked(2 + 4)` | `2 + 4` |

[🔝 Back to Top](#supported-mutators)

## Array Declarator
## Conditional Expression

Original | Mutated
| - | - |
`new Array(1, 2, 3, 4)` | `new Array()`
`[1, 2, 3, 4]` | `[ ]`
| Original | Mutated |
| ---------------------------------- | --------------------------------- |
| `for (var i = 0; i < 10; i++) { }` | `for (var i = 0; false; i++) { }` |
| `while (a > b) { }` | `while (false) { }` |
| `do { } while (a > b);` | `do { } while (false);` |
| `if (a > b) { }` | `if (true) { }` |
| `if (a > b) { }` | `if (false) { }` |
| `var x = a > b ? 1 : 2;` | `var x = true ? 1 : 2;` |
| `var x = a > b ? 1 : 2;` | `var x = false ? 1 : 2;` |

[🔝 Back to Top](#supported-mutators)

## String mutator
## Equality Operator

| Original | Mutated |
| --------- | ----------- |
| `a < b` | `a <= b` |
| `a < b` | `a >= b` |
| `a <= b` | `a < b` |
| `a <= b` | `a > b` |
| `a > b` | `a >= b` |
| `a > b` | `a <= b` |
| `a >= b` | `a > b` |
| `a >= b` | `a < b` |
| `a == b` | `a != b` |
| `a != b` | `a == b` |
| `a === b` | `a !== b` ¹ |
| `a !== b` | `a === b` ¹ |

- ¹: Only supported on StrykerJS

[🔝 Back to Top](#supported-mutators)

Original | Mutated
| - | - |
`"foo"` (non-empty string) | `""` (empty string)
`""` (empty string) | `"Stryker was here!"`
`s"foo ${bar}"` (string interpolation) | `s""` ¹
## Logical Operator

¹ Only works with string interpolation and not others (like Scalameta quasiquotes) to avoid compile errors
| Original | Mutated |
| ---------- | ---------- |
| `a && b` | `a \|\| b` |
| `a \|\| b` | `a && b` |

[🔝 Back to Top](#supported-mutators)

## Block statement
## Method Expression

Due to differences in language syntax, method expressions are implemented differently in each Stryker framework:

### Stryker.NET:

| Original | Mutated |
| --------------------- | ------------------- |
| `Distinct()` | ` ` |
| `Reverse()` | ` ` |
| `OrderBy()` | ` ` |
| `OrderByDescending()` | ` ` |
| `SingleOrDefault()` | `FirstOrDefault()` |
| `FirstOrDefault()` | `SingleOrDefault()` |
| `First()` | `Last()` |
| `Last()` | `First()` |
| `All()` | `Any()` |
| `Any()` | `All()` |
| `Skip()` | `Take()` |
| `Take()` | `Skip()` |
| `SkipWhile()` | `TakeWhile()` |
| `TakeWhile()` | `SkipWhile()` |
| `Min()` | `Max()` |
| `Max()` | `Min()` |
| `Sum()` | `Count()` |
| `Count()` | `Sum()` |

### Stryker4s:

| Original | Mutated |
| ------------------ | ------------------ |
| `a.filter(b)` | `a.filterNot(b)` |
| `a.filterNot(b)` | `a.filter(b)` |
| `a.exists(b)` | `a.forAll(b)` |
| `a.forAll(b)` | `a.exists(b)` |
| `a.drop(b)` | `a.take(b)` |
| `a.take(b)` | `a.drop(b)` |
| `a.isEmpty` | `a.nonEmpty` |
| `a.nonEmpty` | `a.isEmpty` |
| `a.indexOf` | `a.lastIndexOf(b)` |
| `a.lastIndexOf(b)` | `a.indexOf(b)` |
| `a.max` | `a.min` |
| `a.min` | `a.max` |

This mutator removes the content of every block statement. For example the code:
[🔝 Back to Top](#supported-mutators)

```javascript
function saySomething() {
console.log('Hello world!');
}
```
## String Literal

becomes:
| Original | Mutated |
| -------------------------------------- | --------------------- |
| `"foo"` (non-empty string) | `""` (empty string) |
| `""` (empty string) | `"Stryker was here!"` |
| `s"foo ${bar}"` (string interpolation) | `s""` ¹ |

```javascript
function saySomething() {
}
```
¹ For Stryker4s, only works with string interpolation and not other types of interpolation (like [Scalameta quasiquotes](https://scalameta.org/docs/trees/guide.html#with-quasiquotes)) to avoid compile errors

[🔝 Back to Top](#supported-mutators)

## Checked mutator
## Unary Operator

Stryker.NET *specific mutator*

Original | Mutated
| - | - |
`checked(2 + 4)` | `2 + 4`
| Original | Mutated |
| -------- | ------- |
| `+a` | `-a` |
| `-a` | `+a` |

[🔝 Back to Top](#supported-mutators)

## Method mutator

Original | Mutated
| - | - |
`a.filter(b)` | `a.filterNot(b)`
`a.filterNot(b)` | `a.filter(b)`
`a.exists(b`) | `a.forAll(b)`
`a.forAll(b)` | `a.exists(b)`
`a.isEmpty` | `a.nonEmpty`
`a.nonEmpty` | `a.isEmpty`
`a.indexOf` | `a.lastIndexOf(b)`
`a.lastIndexOf(b)` | `a.indexOf(b)`
`a.max` | `a.min`
`a.min` | `a.max`
## Update Operator

| Original | Mutated |
| -------- | ------- |
| `a++` | `a--` |
| `a--` | `a++` |
| `++a` | `--a` |
| `--a` | `++a` |

[🔝 Back to Top](#supported-mutators)

0 comments on commit 5b5eb82

Please sign in to comment.