From 28d5a1023ddc83d1c11acc44403dffd0b742b6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=92=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= Date: Fri, 26 Jun 2026 18:10:57 +0300 Subject: [PATCH] fix: rely on wrap argument metadata validation --- src/core/operations/Wrap.mjs | 11 ----------- tests/operations/tests/Wrap.mjs | 33 --------------------------------- 2 files changed, 44 deletions(-) diff --git a/src/core/operations/Wrap.mjs b/src/core/operations/Wrap.mjs index 303ea9e2..004246ac 100644 --- a/src/core/operations/Wrap.mjs +++ b/src/core/operations/Wrap.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import OperationError from "../errors/OperationError.mjs"; const MAX_LINE_WIDTH = 65536; @@ -45,16 +44,6 @@ class Wrap extends Operation { run(input, args) { if (!input) return ""; // Handle empty input const lineWidth = args[0]; - - if (!Number.isInteger(lineWidth)) - throw new OperationError("Line Width must be an integer."); - - if (lineWidth < 1) - throw new OperationError("Line Width must be greater than or equal to 1."); - - if (lineWidth > MAX_LINE_WIDTH) - throw new OperationError(`Line Width must be less than or equal to ${MAX_LINE_WIDTH}.`); - const regex = new RegExp(`.{1,${lineWidth}}`, "g"); return input.match(regex).join("\n"); } diff --git a/tests/operations/tests/Wrap.mjs b/tests/operations/tests/Wrap.mjs index 2373d070..8d7c9a51 100644 --- a/tests/operations/tests/Wrap.mjs +++ b/tests/operations/tests/Wrap.mjs @@ -40,38 +40,5 @@ TestRegister.addTests([ "args": [10] }, ], - }, - { - name: "Wrap rejects negative line width", - input: "hi, how about you", - expectedOutput: "Line Width must be greater than or equal to 1.", - recipeConfig: [ - { - "op": "Wrap", - "args": [-1] - }, - ], - }, - { - name: "Wrap rejects floating-point line width", - input: "hi, how about you", - expectedOutput: "Line Width must be an integer.", - recipeConfig: [ - { - "op": "Wrap", - "args": [1.1] - }, - ], - }, - { - name: "Wrap rejects excessively large line width", - input: "hi, how about you", - expectedOutput: "Line Width must be less than or equal to 65536.", - recipeConfig: [ - { - "op": "Wrap", - "args": [1.1761717177171882e+23] - }, - ], } ]);