Socket
Socket
Sign inDemoInstall

weapon-regex

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0 to 1.0.0

index.d.ts

7

package.json
{
"name": "weapon-regex",
"version": "0.6.0",
"description": "weapon-regex",
"main": "core/target/js-2.13/weapon-regex-opt/main.js",
"type": "module",
"version": "1.0.0",
"description": "Weapon regeX mutates regular expressions for use in mutation testing.",
"main": "./index.js",
"repository": {

@@ -7,0 +8,0 @@ "type": "git",

@@ -9,6 +9,6 @@ # Weapon regeX

Weapon regeX mutates regular expressions for use in mutation testing. It has been designed from the ground up
Weapon regeX mutates regular expressions for use in mutation testing. It has been designed from the ground up
to support [Stryker Mutator](https://github.com/stryker-mutator). Weapon regeX is available for both
JavaScript and Scala and is used in [Stryker4s](https://github.com/stryker-mutator/stryker4s) and
[StrykerJS](https://github.com/stryker-mutator/stryker-js) flavors of Stryker.
JavaScript and Scala and is used in [Stryker4s](https://github.com/stryker-mutator/stryker4s) and
[StrykerJS](https://github.com/stryker-mutator/stryker-js) flavors of Stryker.
The JavaScript version of the library is generated from Scala using [Scala.js](https://www.scala-js.org/).

@@ -18,6 +18,6 @@ The generated mutant regular expressions cover human errors, such as edge cases and typos. A list of provided mutators is given below.

The current supported versions for Scala are: `2.12` and `2.13`.
# Getting started
In case you want to incorporate Weapon-regeX into your project.

@@ -37,7 +37,6 @@

import weaponregex.WeaponRegeX
import scala.util.{Try, Success, Failure}
WeaponRegeX.mutate("^abc(d+|[xyz])$") match {
case Success(mutants) => mutants map (_.pattern)
case Failure(e) => throw e
case Right(mutants) => mutants map (_.pattern)
case Left(e) => throw new RuntimeException(e)
}

@@ -74,3 +73,3 @@ // res0: Seq[String] = List(

```javascript
const wrx = require('weapon-regex');
import wrx from 'weapon-regex';

@@ -84,2 +83,4 @@ let mutants = wrx.mutate('^abc(d+|[xyz])$');

Note: as of 1.0.0 weapon-regex uses ES Modules.
[![Try it!](https://img.shields.io/static/v1?label=RunKit&message=Try%20it!&color=F55FA6&logo=runkit)](https://npm.runkit.com/weapon-regex)

@@ -103,6 +104,6 @@

flavor: ParserFlavor = ParserFlavorJVM
): Try[Seq[Mutant]] = ???
): Either[String, Seq[Mutant]] = ???
WeaponRegeX.mutate _
// res1: (String, Seq[TokenMutator], Seq[Int], ParserFlavor) => Try[Seq[Mutant]] = <function4>
// res1: (String, Seq[TokenMutator], Seq[Int], ParserFlavor) => Either[String, Seq[Mutant]] = <function4>
```

@@ -117,19 +118,18 @@

The `flavor` argument allows setting the parser flavor that will be used to parse the pattern.
The `flavor` argument allows setting the parser flavor that will be used to parse the pattern.
Currently, we support a `ParserFlavorJVM` and `ParserFlavorJS`. By default in Scala the JVM flavor is used.
This function will return a `Success` with `Seq[Mutant]` if it can be parsed, or a `Failure` otherwise.
This function will return a `Right` with `Seq[Mutant]` if it can be parsed, or a `Left` with the error message otherwise.
## JavaScript
The `mutate` function can be called with an options object to control which mutators and which parser flavor should be
used in the mutation process:
The `mutate` function can be called with regular expression flags and an options object to control which mutators and which parser flavor should be used in the mutation process:
```js
const wrx = require('weapon-regex');
import wrx from 'weapon-regex';
let mutants = wrx.mutate('^abc(d+|[xyz])$', {
let mutants = wrx.mutate('^abc(d+|[xyz])$', 'u', {
mutators: Array.from(wrx.mutators.values()),
mutationLevels: [1, 2, 3],
flavor: ParserFlavorJS
flavor: ParserFlavorJS,
});

@@ -140,3 +140,3 @@ ```

API section. By default in JS the JS parser flavor is used. You can get a map of mutators from the `mutators` attribute of the library. It is
a map from string (mutator name) to a mutator object.
a `Map<string, Mutator>` from string (mutator name) to a mutator object.

@@ -149,26 +149,26 @@ This function will return a JavaScript Array of `Mutant` if it can be parsed, or throw an exception otherwise.

| Name | 1 | 2 | 3 |
| Name | 1 | 2 | 3 |
| --------------------------------------------------------------- | --- | --- | --- |
| [BOLRemoval](#bolremoval) | ✅ | ✅ | ✅ |
| [EOLRemoval](#eolremoval) | ✅ | ✅ | ✅ |
| [BOL2BOI](#bol2boi) | | ✅ | ✅ |
| [EOL2EOI](#eol2eoi) | | ✅ | ✅ |
| [CharClassNegation](#charclassnegation) | ✅ |
| [CharClassChildRemoval](#charclasschildremoval) | | ✅ | ✅ |
| [CharClassAnyChar](#charclassanychar) | | ✅ | ✅ |
| [CharClassRangeModification](#charclassrangemodification) | | | ✅ |
| [PredefCharClassNegation](#predefcharclassnegation) | ✅ |
| [PredefCharClassNullification](#predefcharclassnullification) | | ✅ | ✅ |
| [PredefCharClassAnyChar](#predefcharclassanychar) | | ✅ | ✅ |
| [POSIXCharClassNegation](#posixcharclassnegation) | ✅ |
| [QuantifierRemoval](#quantifierremoval) | ✅ |
| [QuantifierNChange](#quantifiernchange) | | ✅ | ✅ |
| [QuantifierNOrMoreModification](#quantifiernormoremodification) | | ✅ | ✅ |
| [QuantifierNOrMoreChange](#quantifiernormorechange) | | ✅ | ✅ |
| [QuantifierNMModification](#quantifiernmmodification) | | ✅ | ✅ |
| [QuantifierShortModification](#quantifiershortmodification) | | ✅ | ✅ |
| [QuantifierShortChange](#quantifiershortchange) | | ✅ | ✅ |
| [QuantifierReluctantAddition](#quantifierreluctantaddition) | | | ✅ |
| [GroupToNCGroup](#grouptoncgroup) | | ✅ | ✅ |
| [LookaroundNegation](#lookaroundnegation) | ✅ | ✅ | ✅ |
| [BOLRemoval](#bolremoval) | ✅ | ✅ | ✅ |
| [EOLRemoval](#eolremoval) | ✅ | ✅ | ✅ |
| [BOL2BOI](#bol2boi) | | ✅ | ✅ |
| [EOL2EOI](#eol2eoi) | | ✅ | ✅ |
| [CharClassNegation](#charclassnegation) | ✅ |
| [CharClassChildRemoval](#charclasschildremoval) | | ✅ | ✅ |
| [CharClassAnyChar](#charclassanychar) | | ✅ | ✅ |
| [CharClassRangeModification](#charclassrangemodification) | | | ✅ |
| [PredefCharClassNegation](#predefcharclassnegation) | ✅ |
| [PredefCharClassNullification](#predefcharclassnullification) | | ✅ | ✅ |
| [PredefCharClassAnyChar](#predefcharclassanychar) | | ✅ | ✅ |
| [POSIXCharClassNegation](#posixcharclassnegation) | ✅ |
| [QuantifierRemoval](#quantifierremoval) | ✅ |
| [QuantifierNChange](#quantifiernchange) | | ✅ | ✅ |
| [QuantifierNOrMoreModification](#quantifiernormoremodification) | | ✅ | ✅ |
| [QuantifierNOrMoreChange](#quantifiernormorechange) | | ✅ | ✅ |
| [QuantifierNMModification](#quantifiernmmodification) | | ✅ | ✅ |
| [QuantifierShortModification](#quantifiershortmodification) | | ✅ | ✅ |
| [QuantifierShortChange](#quantifiershortchange) | | ✅ | ✅ |
| [QuantifierReluctantAddition](#quantifierreluctantaddition) | | | ✅ |
| [GroupToNCGroup](#grouptoncgroup) | | ✅ | ✅ |
| [LookaroundNegation](#lookaroundnegation) | ✅ | ✅ | ✅ |

@@ -454,12 +454,11 @@ ## Boundary Mutators

| Original | Mutated |
| ----------- | ---------- |
| `(?=abc)` | `(?!abc)` |
| `(?!abc)` | `(?=abc)` |
| `(?<=abc)` | `(?<!abc)` |
| `(?<!abc)` | `(?<=abc)` |
| Original | Mutated |
| ---------- | ---------- |
| `(?=abc)` | `(?!abc)` |
| `(?!abc)` | `(?=abc)` |
| `(?<=abc)` | `(?<!abc)` |
| `(?<!abc)` | `(?<=abc)` |
[Back to table 🔝](#supported-mutators)
_Copyright 2021 Stryker mutator team_

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc