Skip to content

Commit c45d471

Browse files
author
kokobd
committed
fix test case
1 parent eed3a65 commit c45d471

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lsp-types/test/URIFilePathSpec.hs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ genValidUnicodeChar = arbitraryUnicodeChar `suchThat` isCharacter
265265
where isCharacter x = x /= '\65534' && x /= '\65535'
266266

267267
normalizedFilePathSpec :: Spec
268-
normalizedFilePathSpec = do
268+
normalizedFilePathSpec = beforeAll (setFileSystemEncoding utf8) $ do
269269
it "makes file path normalized" $ property $ forAll genFilePath $ \fp -> do
270270
let nfp = toNormalizedFilePath fp
271271
fromNormalizedFilePath nfp `shouldBe` (normalise fp)
@@ -297,14 +297,15 @@ normalizedFilePathSpec = do
297297
it "converts to NormalizedFilePath and back sucessfully" $ property $ forAll genFilePath $ \fp -> do
298298
let osPath = fromJust (OsPath.encodeUtf fp)
299299
osPath' <- osPathToNormalizedFilePath osPath >>= normalizedFilePathToOsPath
300-
osPath' `shouldBe` osPath
301-
302-
it "can not convert OsPath in non-standard encoding to NormalizedFilePath" $ do
303-
-- \184921 is an example that the raw bytes of UTF16 is not valid UTF8.
304-
-- Case like this is not very common. I found it with the help of QuickCheck.
305-
setFileSystemEncoding utf8
306-
case OsPath.encodeWith utf16be utf16be "\184921" of
307-
Left err -> throwIO err
308-
Right osPath -> do
309-
osPathToNormalizedFilePath osPath `shouldThrow` \(_ :: IOException) -> True
300+
osPath' `shouldBe` OsPath.normalise osPath
301+
302+
it "can not convert OsPath in non-standard encoding to NormalizedFilePath" $
303+
-- Windows always use UTF16LE, the following test case doesn't apply
304+
when (not isWindows) $
305+
-- \184921 is an example that the raw bytes of UTF16 is not valid UTF8.
306+
-- Case like this is not very common. I found it with the help of QuickCheck.
307+
case OsPath.encodeWith utf16be utf16be "\184921" of
308+
Left err -> throwIO err
309+
Right osPath -> do
310+
osPathToNormalizedFilePath osPath `shouldThrow` \(_ :: IOException) -> True
310311
#endif

0 commit comments

Comments
 (0)