-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[completion] Follow LSP and treat positions as UTF16 code units
- Loading branch information
Showing
9 changed files
with
168 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(test | ||
(name unittests) | ||
(link_flags -linkall) | ||
(libraries alcotest controller)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(* Build with `ocamlbuild -pkg alcotest simple.byte` *) | ||
|
||
open Coq | ||
|
||
let testcases_x = | ||
[ ("aax", 2, true) | ||
; (" xoo", 2, true) | ||
; ("0123", 4, false) | ||
; (" 𝒞x", 4, true) | ||
; (" 𝒞x𝒞", 4, true) | ||
; (" 𝒞∫x", 5, true) | ||
; (" 𝒞", 4, false) | ||
; ("∫x.dy", 1, true) | ||
] | ||
|
||
(* The tests *) | ||
let test_x () = | ||
List.iter | ||
(fun (s, i, b) -> | ||
let res = Utf8.get_byte_offset_from_utf16_pos s i in | ||
if b then | ||
let res = Option.map (fun i -> s.[i]) res in | ||
Alcotest.(check (option char)) "x present" (Some 'x') res | ||
else Alcotest.(check (option int)) "x present" None res) | ||
testcases_x | ||
|
||
(* Run it *) | ||
let () = | ||
let open Alcotest in | ||
run "Controller" [ ("utf16", [ test_case "Find the x" `Quick test_x ]) ] |