projects
/
lsp-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
14c48f7
)
Export satisfy
0.5.2.0
author
Luke Lau
<luke_lau@icloud.com>
Sun, 28 Apr 2019 22:46:51 +0000
(23:46 +0100)
committer
Luke Lau
<luke_lau@icloud.com>
Sun, 28 Apr 2019 22:46:51 +0000
(23:46 +0100)
ChangeLog.md
patch
|
blob
|
history
lsp-test.cabal
patch
|
blob
|
history
src/Language/Haskell/LSP/Test.hs
patch
|
blob
|
history
src/Language/Haskell/LSP/Test/Parsing.hs
patch
|
blob
|
history
src/Language/Haskell/LSP/Test/Session.hs
patch
|
blob
|
history
test/Test.hs
patch
|
blob
|
history
diff --git
a/ChangeLog.md
b/ChangeLog.md
index 3af75a6d1678271ad14bb4a4d868186ec4a8ef6d..9397bfde64d484a39456a7a6948e3d2d49588649 100644
(file)
--- a/
ChangeLog.md
+++ b/
ChangeLog.md
@@
-1,5
+1,9
@@
# Revision history for lsp-test
# Revision history for lsp-test
+## 0.5.2.0 -- 2019-04-28
+
+* Add `satisfy` parser combinator
+
## 0.5.1.0 -- 2019-04-22
* Fix unhandled `window/progress` server notifications
## 0.5.1.0 -- 2019-04-22
* Fix unhandled `window/progress` server notifications
diff --git
a/lsp-test.cabal
b/lsp-test.cabal
index dd90f8bc379deb36ae1b1dba057128c522451198..a55bc40d3621927b2447c003770df47c9da32efb 100644
(file)
--- a/
lsp-test.cabal
+++ b/
lsp-test.cabal
@@
-1,5
+1,5
@@
name: lsp-test
name: lsp-test
-version: 0.5.
1.4
+version: 0.5.
2.0
synopsis: Functional test framework for LSP servers.
description:
A test framework for writing tests against
synopsis: Functional test framework for LSP servers.
description:
A test framework for writing tests against
diff --git
a/src/Language/Haskell/LSP/Test.hs
b/src/Language/Haskell/LSP/Test.hs
index 1b24fb74d11abea61c24c0b7e4f45bfd6b075419..4a1936db5e544a67ef57b7cb2db102f2252b5a18 100644
(file)
--- a/
src/Language/Haskell/LSP/Test.hs
+++ b/
src/Language/Haskell/LSP/Test.hs
@@
-351,7
+351,7
@@
waitForDiagnosticsSource src = do
matches d = d ^. source == Just (T.pack src)
-- | Expects a 'PublishDiagnosticsNotification' and throws an
matches d = d ^. source == Just (T.pack src)
-- | Expects a 'PublishDiagnosticsNotification' and throws an
--- 'UnexpectedDiagnostics
Exception'
if there are any diagnostics
+-- 'UnexpectedDiagnostics
' exception
if there are any diagnostics
-- returned.
noDiagnostics :: Session ()
noDiagnostics = do
-- returned.
noDiagnostics :: Session ()
noDiagnostics = do
diff --git
a/src/Language/Haskell/LSP/Test/Parsing.hs
b/src/Language/Haskell/LSP/Test/Parsing.hs
index 1fd394f3db1ee96a6810a25fa4e62e9be9f235e2..09006b67859957aedab3ac045a3926ad09598037 100644
(file)
--- a/
src/Language/Haskell/LSP/Test/Parsing.hs
+++ b/
src/Language/Haskell/LSP/Test/Parsing.hs
@@
-5,7
+5,8
@@
module Language.Haskell.LSP.Test.Parsing
( -- $receiving
module Language.Haskell.LSP.Test.Parsing
( -- $receiving
- message
+ satisfy
+ , message
, anyRequest
, anyResponse
, anyNotification
, anyRequest
, anyResponse
, anyNotification
@@
-60,6
+61,9
@@
import Language.Haskell.LSP.Test.Session
-- anyResponse
-- @
-- anyResponse
-- @
+-- | Consumes and returns the next message, if it satisfies the specified predicate.
+--
+-- @since 0.5.2.0
satisfy :: (FromServerMessage -> Bool) -> Session FromServerMessage
satisfy pred = do
satisfy :: (FromServerMessage -> Bool) -> Session FromServerMessage
satisfy pred = do
@@
-85,7
+89,7
@@
satisfy pred = do
return x
else empty
return x
else empty
--- | Matches a message of type
'a'
.
+-- | Matches a message of type
@a@
.
message :: forall a. (Typeable a, FromJSON a) => Session a
message =
let parser = decode . encodeMsg :: FromServerMessage -> Maybe a
message :: forall a. (Typeable a, FromJSON a) => Session a
message =
let parser = decode . encodeMsg :: FromServerMessage -> Maybe a
diff --git
a/src/Language/Haskell/LSP/Test/Session.hs
b/src/Language/Haskell/LSP/Test/Session.hs
index 700d9ccc84c233314f9c581bfd6bf8f810c8c1d5..291a3e0bcaa990327988f2bcbd9df6554a63f50f 100644
(file)
--- a/
src/Language/Haskell/LSP/Test/Session.hs
+++ b/
src/Language/Haskell/LSP/Test/Session.hs
@@
-68,9
+68,10
@@
import System.IO
-- | A session representing one instance of launching and connecting to a server.
--
-- | A session representing one instance of launching and connecting to a server.
--
--- You can send and receive messages to the server within 'Session' via 'getMessage',
--- 'sendRequest' and 'sendNotification'.
---
+-- You can send and receive messages to the server within 'Session' via
+-- 'Language.Haskell.LSP.Test.message',
+-- 'Language.Haskell.LSP.Test.sendRequest' and
+-- 'Language.Haskell.LSP.Test.sendNotification'.
type Session = ParserStateReader FromServerMessage SessionState SessionContext IO
type Session = ParserStateReader FromServerMessage SessionState SessionContext IO
@@
-296,7
+297,7
@@
sendMessage msg = do
logMsg LogClient msg
liftIO $ B.hPut h (addHeader $ encode msg)
logMsg LogClient msg
liftIO $ B.hPut h (addHeader $ encode msg)
--- | Execute a block f that will throw a 'Timeout
Exception'
+-- | Execute a block f that will throw a 'Timeout
' exception
-- after duration seconds. This will override the global timeout
-- for waiting for messages to arrive defined in 'SessionConfig'.
withTimeout :: Int -> Session a -> Session a
-- after duration seconds. This will override the global timeout
-- for waiting for messages to arrive defined in 'SessionConfig'.
withTimeout :: Int -> Session a -> Session a
diff --git
a/test/Test.hs
b/test/Test.hs
index 0fc2f53f73d2511b480a83b7ef770e83ba9acba9..377bb6d1f15fdedc36c3669e13263d2909322ab9 100644
(file)
--- a/
test/Test.hs
+++ b/
test/Test.hs
@@
-319,6
+319,13
@@
main = hspec $ do
documentContents doc >>= liftIO . print
in sesh `shouldThrow` anyException
documentContents doc >>= liftIO . print
in sesh `shouldThrow` anyException
+ describe "satisfy" $
+ it "works" $ runSession "hie" fullCaps "test/data" $ do
+ openDoc "Format.hs" "haskell"
+ let pred (NotLogMessage _) = True
+ pred _ = False
+ void $ satisfy pred
+
mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
didChangeCaps :: ClientCapabilities
mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
didChangeCaps :: ClientCapabilities