Skip to content

Commit 4a36269

Browse files
committed
Add some basic tests
1 parent 01d305e commit 4a36269

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lsp/test/VspSpec.hs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,31 @@ vspSpec = do
299299
, " putStrLn \"hello world\""
300300
]
301301

302+
it "converts code units to code points" $ do
303+
let
304+
orig = unlines
305+
[ "a𐐀b"
306+
, "a𐐀b"
307+
]
308+
vfile = VirtualFile 0 0 (fromString orig)
309+
310+
positionToCodePointPosition vfile (J.Position 1 0)`shouldBe` Just (CodePointPosition 1 0)
311+
positionToCodePointPosition vfile (J.Position 1 1)`shouldBe` Just (CodePointPosition 1 1)
312+
positionToCodePointPosition vfile (J.Position 1 2)`shouldBe` Nothing
313+
positionToCodePointPosition vfile (J.Position 1 3)`shouldBe` Just (CodePointPosition 1 2)
314+
315+
it "converts code points to code units" $ do
316+
let
317+
orig = unlines
318+
[ "a𐐀b"
319+
, "a𐐀b"
320+
]
321+
vfile = VirtualFile 0 0 (fromString orig)
322+
323+
codePointPositionToPosition vfile (CodePointPosition 1 0)`shouldBe` J.Position 1 0
324+
codePointPositionToPosition vfile (CodePointPosition 1 1)`shouldBe` J.Position 1 1
325+
codePointPositionToPosition vfile (CodePointPosition 1 2)`shouldBe` J.Position 1 3
326+
302327
-- ---------------------------------
303328

304329
it "getCompletionPrefix" $ do

0 commit comments

Comments
 (0)