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
41 lines
1.0 KiB
Plaintext
41 lines
1.0 KiB
Plaintext
xquery version "3.1";
|
|
|
|
(: Common XQuery utility functions :)
|
|
|
|
declare namespace app = "http://example.com/app";
|
|
|
|
declare function app:validate-input($value as xs:string) as xs:boolean {
|
|
string-length($value) gt 0
|
|
and string-length($value) le 255
|
|
};
|
|
|
|
declare function app:parse-int($s as xs:string) as xs:integer? {
|
|
if (matches($s, '^\d+$'))
|
|
then xs:integer($s)
|
|
else ()
|
|
};
|
|
|
|
declare function app:filter-active($items as element()*) as element()* {
|
|
$items[@active = 'true']
|
|
};
|
|
|
|
declare function app:map-names($items as element()*) as xs:string* {
|
|
for $item in $items
|
|
return upper-case($item/@name/string())
|
|
};
|
|
|
|
declare function app:sum-values($items as element()*) as xs:decimal {
|
|
sum($items/@value/number())
|
|
};
|
|
|
|
(: File-specific: get user by id :)
|
|
declare function app:get-user($users as element()*, $id as xs:integer) as element()? {
|
|
$users[@id = $id][1]
|
|
};
|
|
|
|
let $users := (
|
|
<user id="1" name="alice" value="100" active="true"/>,
|
|
<user id="2" name="bob" value="200" active="false"/>
|
|
)
|
|
return app:sum-values($users)
|