|
| 1 | +/** |
| 2 | + * @overview Contains differential tests for the migration form standard regular |
| 3 | + * expressions to linear-time regular expressions in PoewrShell. |
| 4 | + * @license MIT |
| 5 | + */ |
| 6 | + |
| 7 | +import { testProp } from "@fast-check/ava"; |
| 8 | +import * as fc from "fast-check"; |
| 9 | + |
| 10 | +import * as old from "../../../node_modules/shescape-previous/src/internal/win/powershell.js"; |
| 11 | +import * as upd from "../../../src/internal/win/powershell.js"; |
| 12 | + |
| 13 | +testProp( |
| 14 | + "escape functionality is unchanged", |
| 15 | + [fc.string()], |
| 16 | + (t, arg) => { |
| 17 | + const updFn = upd.getEscapeFunction(); |
| 18 | + const oldFn = old.getEscapeFunction(); |
| 19 | + |
| 20 | + const got = updFn(arg); |
| 21 | + const want = oldFn(arg); |
| 22 | + t.is(got, want); |
| 23 | + }, |
| 24 | + { numRuns: 1_000_000 }, |
| 25 | +); |
| 26 | + |
| 27 | +testProp( |
| 28 | + "quote functionality is unchanged", |
| 29 | + [fc.string()], |
| 30 | + (t, arg) => { |
| 31 | + const updFn = upd.getQuoteFunction(); |
| 32 | + const oldFn = old.getQuoteFunction(); |
| 33 | + |
| 34 | + const got = updFn[0](updFn[1](arg)); |
| 35 | + const want = oldFn[0](oldFn[1](arg)); |
| 36 | + t.is(got, want); |
| 37 | + }, |
| 38 | + { numRuns: 1_000_000 }, |
| 39 | +); |
| 40 | + |
| 41 | +testProp( |
| 42 | + "flag protection functionality is unchanged", |
| 43 | + [fc.string()], |
| 44 | + (t, arg) => { |
| 45 | + const updFn = upd.getFlagProtectionFunction(); |
| 46 | + const oldFn = old.getFlagProtectionFunction(); |
| 47 | + |
| 48 | + const got = updFn(arg); |
| 49 | + const want = oldFn(arg); |
| 50 | + t.is(got, want); |
| 51 | + }, |
| 52 | + { numRuns: 1_000_000 }, |
| 53 | +); |
0 commit comments