[mod] improve sock err handling
This commit is contained in:
parent
9c805c2a21
commit
b7d0d8e03d
11 changed files with 108 additions and 71 deletions
|
|
@ -1,53 +0,0 @@
|
|||
xquery version '3.1';
|
||||
(:~
|
||||
tests for position test
|
||||
@author: Andy Bunce
|
||||
@date: 2025/08/11
|
||||
:)
|
||||
module namespace test = 'lsp/test/position';
|
||||
|
||||
import module namespace pos="lsp/position" at "../webapp/lsp/position.xqm";
|
||||
|
||||
|
||||
(:~ count lines. :)
|
||||
declare %unit:test function test:line-count() {
|
||||
let $text:=unparsed-text("sample.docs/pdfbox.xqm")
|
||||
let $nl:= index-of(string-to-codepoints($text),10)
|
||||
return unit:assert-equals(count($nl),521)
|
||||
};
|
||||
|
||||
(:~ convert position. :)
|
||||
declare %unit:test function test:resolvePosition() {
|
||||
let $text:=unparsed-text("sample.docs/pdfbox.xqm")
|
||||
let $p:= pos:resolvePosition($text,pos:Position(518,33))
|
||||
return unit:assert-equals($p,18751)
|
||||
};
|
||||
|
||||
(:~ convert position. :)
|
||||
declare %unit:test("expected", "pos:range")
|
||||
function test:toPosition() {
|
||||
let $text:="1+2 a"
|
||||
return pos:toPosition($text,5)
|
||||
};
|
||||
(:~ convert position. :)
|
||||
declare %unit:test
|
||||
function test:toPosition2() {
|
||||
let $text:="1+2 a"
|
||||
return unit:assert-equals(pos:toPosition($text,4),{"line":0,"character":4})
|
||||
};
|
||||
|
||||
(:~ convert all position. :)
|
||||
declare %unit:test %unit:ignore function test:toPositionAll() {
|
||||
let $text:=unparsed-text("sample.docs/pdfbox.xqm")
|
||||
return for $i in 0 to string-length($text)-1
|
||||
let $pos:=pos:toPosition($text,$i)
|
||||
return unit:assert-equals($i,pos:resolvePosition($text,$pos))
|
||||
};
|
||||
|
||||
(:~ convert position. :)
|
||||
declare %unit:test function test:line() {
|
||||
let $text:=unparsed-text("sample.docs/pdfbox.xqm")
|
||||
let $nl:= index-of(string-to-codepoints($text),10)
|
||||
let $p:= pos:lineAt($nl,18752)=>trace("AA")
|
||||
return unit:assert-equals($p,518)
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue