mutation.test.ts 837 B

1234567891011121314151617181920212223242526272829
  1. import { describe, expect, test } from "bun:test"
  2. import { ShellScan } from "../src/index.js"
  3. describe("ShellScan structural mutation closure", () => {
  4. test.each([
  5. "$COMMAND status",
  6. "${COMMAND} status",
  7. '"$COMMAND" status',
  8. "$(printf git) status",
  9. "`printf git` status",
  10. 'printf "unterminated',
  11. "printf ok &&",
  12. "| printf ok",
  13. "printf ok >",
  14. ])("keeps unknowable or malformed Bash input opaque: %s", (source) => {
  15. expect(ShellScan.scan(source).kind).toBe("opaque")
  16. })
  17. test.each([
  18. "$Command status",
  19. "${Command} status",
  20. "& $Command status",
  21. "Write-Output ok`",
  22. 'Write-Output "unterminated',
  23. "Get-ChildItem |",
  24. ])("keeps unknowable or malformed PowerShell input opaque: %s", (source) => {
  25. expect(ShellScan.scanPowerShell(source).kind).toBe("opaque")
  26. })
  27. })