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
33 lines
673 B
Prolog
33 lines
673 B
Prolog
% Common utility predicates
|
|
|
|
validate_input(Value, ok) :-
|
|
atom(Value),
|
|
atom_length(Value, Len),
|
|
Len > 0,
|
|
Len =< 255.
|
|
validate_input(_, error("Invalid input")).
|
|
|
|
parse_int(Str, Int) :-
|
|
atom_codes(Str, Codes),
|
|
number_codes(Int, Codes).
|
|
|
|
list_sum([], 0).
|
|
list_sum([H|T], Sum) :-
|
|
list_sum(T, Rest),
|
|
Sum is H + Rest.
|
|
|
|
list_max([X], X).
|
|
list_max([H|T], Max) :-
|
|
list_max(T, TMax),
|
|
(H > TMax -> Max = H ; Max = TMax).
|
|
|
|
member_check(Elem, [Elem|_]).
|
|
member_check(Elem, [_|T]) :-
|
|
member_check(Elem, T).
|
|
|
|
% File-specific: list minimum
|
|
list_min([X], X).
|
|
list_min([H|T], Min) :-
|
|
list_min(T, TMin),
|
|
(H < TMin -> Min = H ; Min = TMin).
|