[mod] tests
This commit is contained in:
parent
c0814be67c
commit
d3a89a5b08
1 changed files with 33 additions and 11 deletions
|
|
@ -25,23 +25,33 @@ second line"
|
|||
return test:expected($doc,$doci,2)
|
||||
|
||||
};
|
||||
(:~ we can create record from string :)
|
||||
(:~ we can create update from string :)
|
||||
declare %unit:test function test:update1() {
|
||||
let $doc:="123456789"
|
||||
let $doci:= doci:build($doc)
|
||||
let $change:=doci:TextDocumentContentChangeEvent(
|
||||
"*",
|
||||
doci:Range(doci:Position(0,0),doci:Position(0,0))
|
||||
)
|
||||
|
||||
let $change:=test:change("*",0,0,0,0)
|
||||
let $doci2:=doci:change($doci,$change)=>trace("A")
|
||||
let $change2:=doci:TextDocumentContentChangeEvent(
|
||||
"",
|
||||
doci:Range(doci:Position(0,0),doci:Position(0,1))
|
||||
)
|
||||
let $update:=doci:change($doci2,$change2)=>trace("b")
|
||||
|
||||
let $change2:=test:change("",0,0,0,1)
|
||||
let $update:=doci:change($doci2,$change2)=>trace("b")
|
||||
return ()
|
||||
};
|
||||
|
||||
(:~ we can create update from string :)
|
||||
declare %unit:test function test:update2() {
|
||||
let $doc:="a
|
||||
123456789
|
||||
b"
|
||||
let $doci:= doci:build($doc)
|
||||
let $_:=test:expected($doc,$doci,3)
|
||||
let $change:=test:change("*",1,9,1,9)
|
||||
let $doci2:=doci:change($doci,$change)=>trace("A")
|
||||
|
||||
let $change2:=test:change("",1,9,1,10)
|
||||
let $update:=doci:change($doci2,$change2)=>trace("b")
|
||||
return ()
|
||||
};
|
||||
|
||||
(: test $doci properties as expected :)
|
||||
declare function test:expected($doc as xs:string, $doci as doci:doci, $lines as xs:integer){
|
||||
unit:assert-equals($doci?lines=>count(),$lines),
|
||||
|
|
@ -60,3 +70,15 @@ declare function test:read($path as xs:string)
|
|||
as xs:string{
|
||||
file:resolve-path($path,file:base-dir())=>file:read-text()
|
||||
};
|
||||
|
||||
(: create a change description:)
|
||||
declare function test:change($text as xs:string,
|
||||
$sline as xs:integer,$schar as xs:integer,
|
||||
$eline as xs:integer,$echar as xs:integer
|
||||
)
|
||||
as doci:TextDocumentContentChangeEvent{
|
||||
doci:TextDocumentContentChangeEvent(
|
||||
$text,
|
||||
doci:Range(doci:Position($sline,$schar),doci:Position($eline,$echar))
|
||||
)
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue