@@ -51,6 +51,7 @@ jsonSpec = do
51
51
-- DataTypesJSON
52
52
prop " MarkedString" (propertyJsonRoundtrip :: MarkedString -> Property )
53
53
prop " MarkupContent" (propertyJsonRoundtrip :: MarkupContent -> Property )
54
+ prop " TextDocumentContentChangeEvent" (propertyJsonRoundtrip :: TextDocumentContentChangeEvent -> Property )
54
55
prop " WatchedFiles" (propertyJsonRoundtrip :: DidChangeWatchedFilesRegistrationOptions -> Property )
55
56
prop " ResponseMessage Hover"
56
57
(propertyJsonRoundtrip :: TResponseMessage 'Method_TextDocumentHover -> Property )
@@ -66,7 +67,7 @@ responseMessageSpec = do
66
67
it " decodes result = null" $ do
67
68
let input = " {\" jsonrpc\" : \" 2.0\" , \" id\" : 123, \" result\" : null}"
68
69
in J. decode input `shouldBe` Just
69
- ((TResponseMessage " 2.0" (Just (IdInt 123 )) (Right $ InR Null )) :: TResponseMessage 'Method_WorkspaceExecuteCommand)
70
+ ((TResponseMessage " 2.0" (Just (IdInt 123 )) (Right $ InL J. Null )) :: TResponseMessage 'Method_WorkspaceExecuteCommand)
70
71
it " handles missing params field" $ do
71
72
J. eitherDecode " { \" jsonrpc\" : \" 2.0\" , \" id\" : 15, \" method\" : \" shutdown\" }"
72
73
`shouldBe` Right (TRequestMessage " 2.0" (IdInt 15 ) SMethod_Shutdown Nothing )
@@ -90,64 +91,79 @@ propertyJsonRoundtrip a = J.Success a === J.fromJSON (J.toJSON a)
90
91
91
92
instance (Arbitrary a , Arbitrary b ) => Arbitrary (a |? b ) where
92
93
arbitrary = oneof [InL <$> arbitrary, InR <$> arbitrary]
94
+ shrink = genericShrink
93
95
94
96
instance Arbitrary Null where
95
97
arbitrary = pure Null
96
98
97
99
instance (R. AllUniqueLabels r , R. Forall r Arbitrary ) => Arbitrary (R. Rec r ) where
98
100
arbitrary = R. fromLabelsA @ Arbitrary $ \ _l -> arbitrary
101
+ shrink record = R. traverse @ Arbitrary @ [] shrink record
99
102
100
103
deriving newtype instance Arbitrary MarkedString
101
104
102
105
instance Arbitrary MarkupContent where
103
106
arbitrary = MarkupContent <$> arbitrary <*> arbitrary
107
+ shrink = genericShrink
104
108
105
109
instance Arbitrary MarkupKind where
106
110
arbitrary = oneof [pure MarkupKind_PlainText ,pure MarkupKind_Markdown ]
111
+ shrink = genericShrink
107
112
108
113
instance Arbitrary UInt where
109
114
arbitrary = fromInteger <$> arbitrary
110
115
111
116
instance Arbitrary Uri where
112
117
arbitrary = Uri <$> arbitrary
118
+ shrink = genericShrink
113
119
114
120
-- deriving newtype instance Arbitrary URI
115
121
116
122
instance Arbitrary WorkspaceFolder where
117
123
arbitrary = WorkspaceFolder <$> arbitrary <*> arbitrary
124
+ shrink = genericShrink
118
125
119
126
instance Arbitrary RelativePattern where
120
127
arbitrary = RelativePattern <$> arbitrary <*> arbitrary
128
+ shrink = genericShrink
121
129
122
130
deriving newtype instance Arbitrary Pattern
123
131
deriving newtype instance Arbitrary GlobPattern
124
132
125
133
instance Arbitrary Position where
126
134
arbitrary = Position <$> arbitrary <*> arbitrary
135
+ shrink = genericShrink
127
136
128
137
instance Arbitrary Location where
129
138
arbitrary = Location <$> arbitrary <*> arbitrary
139
+ shrink = genericShrink
130
140
131
141
instance Arbitrary Range where
132
142
arbitrary = Range <$> arbitrary <*> arbitrary
143
+ shrink = genericShrink
133
144
134
145
instance Arbitrary Hover where
135
146
arbitrary = Hover <$> arbitrary <*> arbitrary
147
+ shrink = genericShrink
136
148
137
149
instance {-# OVERLAPPING #-} Arbitrary (Maybe Void ) where
138
150
arbitrary = pure Nothing
139
151
140
152
instance (ErrorData m ~ Maybe Void ) => Arbitrary (TResponseError m ) where
141
153
arbitrary = TResponseError <$> arbitrary <*> arbitrary <*> pure Nothing
154
+ shrink = genericShrink
142
155
143
156
instance Arbitrary ResponseError where
144
157
arbitrary = ResponseError <$> arbitrary <*> arbitrary <*> pure Nothing
158
+ shrink = genericShrink
145
159
146
160
instance (Arbitrary (MessageResult m ), ErrorData m ~ Maybe Void ) => Arbitrary (TResponseMessage m ) where
147
161
arbitrary = TResponseMessage <$> arbitrary <*> arbitrary <*> arbitrary
162
+ shrink = genericShrink
148
163
149
164
instance Arbitrary (LspId m ) where
150
165
arbitrary = oneof [IdInt <$> arbitrary, IdString <$> arbitrary]
166
+ shrink = genericShrink
151
167
152
168
instance Arbitrary ErrorCodes where
153
169
arbitrary =
@@ -160,6 +176,7 @@ instance Arbitrary ErrorCodes where
160
176
, ErrorCodes_ServerNotInitialized
161
177
, ErrorCodes_UnknownErrorCode
162
178
]
179
+ shrink = genericShrink
163
180
164
181
instance Arbitrary LSPErrorCodes where
165
182
arbitrary =
@@ -169,16 +186,24 @@ instance Arbitrary LSPErrorCodes where
169
186
, LSPErrorCodes_ContentModified
170
187
, LSPErrorCodes_RequestCancelled
171
188
]
189
+ shrink = genericShrink
172
190
-- ---------------------------------------------------------------------
173
191
174
192
instance Arbitrary DidChangeWatchedFilesRegistrationOptions where
175
193
arbitrary = DidChangeWatchedFilesRegistrationOptions <$> arbitrary
194
+ shrink = genericShrink
176
195
177
196
instance Arbitrary FileSystemWatcher where
178
197
arbitrary = FileSystemWatcher <$> arbitrary <*> arbitrary
198
+ shrink = genericShrink
179
199
180
200
-- TODO: watchKind is weird
181
201
instance Arbitrary WatchKind where
182
202
arbitrary = oneof [pure WatchKind_Change , pure WatchKind_Create , pure WatchKind_Delete ]
203
+ shrink = genericShrink
183
204
184
205
-- ---------------------------------------------------------------------
206
+ --
207
+ instance Arbitrary TextDocumentContentChangeEvent where
208
+ arbitrary = TextDocumentContentChangeEvent <$> arbitrary
209
+ shrink = genericShrink
0 commit comments