mirror of
https://github.com/kucherenko/jscpd.git
synced 2026-09-19 08:11:03 +08:00
64e471e2b0
Adds 92 new tests (178 → 270 total) with zero source-file modifications: - packages/finder: 13 new test files covering all reporters, subscribers, validators, hooks, utils, options, cloneFound, getFilesToDetect, and InFilesDetector; shared buildClone() factory helper - apps/jscpd: 3 new test files (options-unit, print, store) plus extensions to formats, modes, and options integration tests - vitest.config.ts added to both packages to restrict coverage.include to src/** only, eliminating bin/ and prism.js noise - Fixes 3 tokenizer bugs (trailing space in format lookup, tokenization edge cases) uncovered by the new format fixture suite - Adds fixture files for 40+ language formats to support formats.test.ts
48 lines
919 B
Plaintext
48 lines
919 B
Plaintext
declare
|
|
fun {ValidateInput Value}
|
|
if {String.length Value} == 0 then
|
|
error(msg: "Input cannot be empty")
|
|
elseif {String.length Value} > 255 then
|
|
error(msg: "Input exceeds maximum length")
|
|
else
|
|
ok(value: Value)
|
|
end
|
|
end
|
|
|
|
fun {ParseInt Str}
|
|
try
|
|
{String.toInt Str}
|
|
catch _ then
|
|
unit
|
|
end
|
|
end
|
|
|
|
fun {MapList Lst Fn}
|
|
case Lst of
|
|
nil then nil
|
|
[] H|T then {Fn H}|{MapList T Fn}
|
|
end
|
|
end
|
|
|
|
fun {FilterList Lst Pred}
|
|
case Lst of
|
|
nil then nil
|
|
[] H|T then
|
|
if {Pred H} then H|{FilterList T Pred}
|
|
else {FilterList T Pred}
|
|
end
|
|
end
|
|
end
|
|
|
|
% File-specific: product of a list
|
|
fun {ProductList Lst}
|
|
case Lst of
|
|
nil then 1
|
|
[] H|T then H * {ProductList T}
|
|
end
|
|
end
|
|
|
|
in
|
|
{Browse {ValidateInput "world"}}
|
|
end
|