@@ -16,18 +16,30 @@ module Hedgehog.Extras.Test.Base
16
16
, noteIO_
17
17
18
18
, noteShow
19
- , noteShow_
20
- , noteShowM
21
- , noteShowM_
19
+ , noteShowPretty
22
20
, noteShowIO
21
+ , noteShowPrettyIO
23
22
, noteShowIO_
23
+ , noteShowPrettyIO_
24
+ , noteShowM
25
+ , noteShowPrettyM
26
+ , noteShowM_
27
+ , noteShowPrettyM_
28
+ , noteShow_
29
+ , noteShowPretty_
24
30
25
31
, noteEach
26
- , noteEach_
27
- , noteEachM
28
- , noteEachM_
32
+ , noteEachPretty
29
33
, noteEachIO
34
+ , noteEachPrettyIO
30
35
, noteEachIO_
36
+ , noteEachPrettyIO_
37
+ , noteEachM
38
+ , noteEachPrettyM
39
+ , noteEachM_
40
+ , noteEachPrettyM_
41
+ , noteEach_
42
+ , noteEachPretty_
31
43
32
44
, noteTempFile
33
45
@@ -119,6 +131,7 @@ import qualified Hedgehog as H
119
131
import qualified Hedgehog.Extras.Internal.Test.Integration as H
120
132
import qualified Hedgehog.Extras.Test.MonadAssertion as H
121
133
import qualified Hedgehog.Internal.Property as H
134
+ import qualified Hedgehog.Internal.Show as H
122
135
import qualified System.Directory as IO
123
136
import qualified System.Environment as IO
124
137
import qualified System.Info as IO
@@ -224,74 +237,161 @@ noteShow a = GHC.withFrozenCallStack $ do
224
237
noteWithCallstack GHC. callStack (show b)
225
238
return b
226
239
240
+ -- | Annotate the given value, pretty printing it with indentation. Note that large data structures will take
241
+ -- a significant amount of vertical screen space.
242
+ noteShowPretty :: (MonadTest m , HasCallStack , Show a ) => a -> m a
243
+ noteShowPretty a = GHC. withFrozenCallStack $ do
244
+ ! b <- H. eval a
245
+ noteWithCallstack GHC. callStack (H. showPretty b)
246
+ return b
247
+
227
248
-- | Annotate the given value returning unit.
228
249
noteShow_ :: (MonadTest m , HasCallStack , Show a ) => a -> m ()
229
250
noteShow_ a = GHC. withFrozenCallStack $ noteWithCallstack GHC. callStack (show a)
230
251
252
+ -- | Annotate the given value returning unit, pretty printing it with indentation. Note that large data structures will take
253
+ -- a significant amount of vertical screen space.
254
+ noteShowPretty_ :: (MonadTest m , HasCallStack , Show a ) => a -> m ()
255
+ noteShowPretty_ a = GHC. withFrozenCallStack $ noteWithCallstack GHC. callStack (H. showPretty a)
256
+
231
257
-- | Annotate the given value in a monadic context.
232
258
noteShowM :: (MonadTest m , MonadCatch m , HasCallStack , Show a ) => m a -> m a
233
259
noteShowM a = GHC. withFrozenCallStack $ do
234
260
! b <- H. evalM a
235
261
noteWithCallstack GHC. callStack (show b)
236
262
return b
237
263
264
+ -- | Annotate the given value in a monadic context, pretty printing it with indentation. Note that large data structures will take
265
+ -- a significant amount of vertical screen space.
266
+ noteShowPrettyM :: (MonadTest m , MonadCatch m , HasCallStack , Show a ) => m a -> m a
267
+ noteShowPrettyM a = GHC. withFrozenCallStack $ do
268
+ ! b <- H. evalM a
269
+ noteWithCallstack GHC. callStack (H. showPretty b)
270
+ return b
271
+
238
272
-- | Annotate the given value in a monadic context returning unit.
239
273
noteShowM_ :: (MonadTest m , MonadCatch m , HasCallStack , Show a ) => m a -> m ()
240
274
noteShowM_ a = GHC. withFrozenCallStack $ do
241
275
! b <- H. evalM a
242
276
noteWithCallstack GHC. callStack (show b)
243
277
return ()
244
278
279
+ -- | Annotate the given value in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take
280
+ -- a significant amount of vertical screen space.
281
+ noteShowPrettyM_ :: (MonadTest m , MonadCatch m , HasCallStack , Show a ) => m a -> m ()
282
+ noteShowPrettyM_ a = GHC. withFrozenCallStack $ do
283
+ ! b <- H. evalM a
284
+ noteWithCallstack GHC. callStack (H. showPretty b)
285
+ return ()
286
+
245
287
-- | Annotate the given value in IO.
246
288
noteShowIO :: (MonadTest m , MonadIO m , HasCallStack , Show a ) => IO a -> m a
247
289
noteShowIO f = GHC. withFrozenCallStack $ do
248
290
! a <- H. evalIO f
249
291
noteWithCallstack GHC. callStack (show a)
250
292
return a
251
293
294
+ -- | Annotate the given value in IO, pretty printing it with indentation. Note that large data structures will take
295
+ -- a significant amount of vertical screen space.
296
+ noteShowPrettyIO :: (MonadTest m , MonadIO m , HasCallStack , Show a ) => IO a -> m a
297
+ noteShowPrettyIO f = GHC. withFrozenCallStack $ do
298
+ ! a <- H. evalIO f
299
+ noteWithCallstack GHC. callStack (H. showPretty a)
300
+ return a
301
+
252
302
-- | Annotate the given value in IO returning unit.
253
303
noteShowIO_ :: (MonadTest m , MonadIO m , HasCallStack , Show a ) => IO a -> m ()
254
304
noteShowIO_ f = GHC. withFrozenCallStack $ do
255
305
! a <- H. evalIO f
256
306
noteWithCallstack GHC. callStack (show a)
257
307
return ()
258
308
309
+ -- | Annotate the given value in IO returning unit, pretty printing it with indentation. Note that large data structures will take
310
+ -- a significant amount of vertical screen space.
311
+ noteShowPrettyIO_ :: (MonadTest m , MonadIO m , HasCallStack , Show a ) => IO a -> m ()
312
+ noteShowPrettyIO_ f = GHC. withFrozenCallStack $ do
313
+ ! a <- H. evalIO f
314
+ noteWithCallstack GHC. callStack (H. showPretty a)
315
+ return ()
316
+
259
317
-- | Annotate the each value in the given traversable.
260
318
noteEach :: (MonadTest m , HasCallStack , Show a , Traversable f ) => f a -> m (f a )
261
319
noteEach as = GHC. withFrozenCallStack $ do
262
320
for_ as $ noteWithCallstack GHC. callStack . show
263
321
return as
264
322
323
+ -- | Annotate the each value in the given traversable, pretty printing it with indentation. Note that large data structures will take
324
+ -- a significant amount of vertical screen space.
325
+ noteEachPretty :: (MonadTest m , HasCallStack , Show a , Traversable f ) => f a -> m (f a )
326
+ noteEachPretty as = GHC. withFrozenCallStack $ do
327
+ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
328
+ return as
329
+
265
330
-- | Annotate the each value in the given traversable returning unit.
266
331
noteEach_ :: (MonadTest m , HasCallStack , Show a , Traversable f ) => f a -> m ()
267
332
noteEach_ as = GHC. withFrozenCallStack $ for_ as $ noteWithCallstack GHC. callStack . show
268
333
334
+ -- | Annotate the each value in the given traversable returning unit, pretty printing it with indentation. Note that large data structures will take
335
+ -- a significant amount of vertical screen space.
336
+ noteEachPretty_ :: (MonadTest m , HasCallStack , Show a , Traversable f ) => f a -> m ()
337
+ noteEachPretty_ as = GHC. withFrozenCallStack $ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
338
+
269
339
-- | Annotate the each value in the given traversable in a monadic context.
270
340
noteEachM :: (MonadTest m , HasCallStack , Show a , Traversable f ) => m (f a ) -> m (f a )
271
341
noteEachM f = GHC. withFrozenCallStack $ do
272
342
! as <- f
273
343
for_ as $ noteWithCallstack GHC. callStack . show
274
344
return as
275
345
346
+ -- | Annotate the each value in the given traversable in a monadic context, pretty printing it with indentation. Note that large data structures will take
347
+ -- a significant amount of vertical screen space.
348
+ noteEachPrettyM :: (MonadTest m , HasCallStack , Show a , Traversable f ) => m (f a ) -> m (f a )
349
+ noteEachPrettyM f = GHC. withFrozenCallStack $ do
350
+ ! as <- f
351
+ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
352
+ return as
353
+
276
354
-- | Annotate the each value in the given traversable in a monadic context returning unit.
277
355
noteEachM_ :: (MonadTest m , HasCallStack , Show a , Traversable f ) => m (f a ) -> m ()
278
356
noteEachM_ f = GHC. withFrozenCallStack $ do
279
357
! as <- f
280
358
for_ as $ noteWithCallstack GHC. callStack . show
281
359
360
+ -- | Annotate the each value in the given traversable in a monadic context returning unit, pretty printing it with indentation. Note that large data structures will take
361
+ -- a significant amount of vertical screen space.
362
+ noteEachPrettyM_ :: (MonadTest m , HasCallStack , Show a , Traversable f ) => m (f a ) -> m ()
363
+ noteEachPrettyM_ f = GHC. withFrozenCallStack $ do
364
+ ! as <- f
365
+ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
366
+
282
367
-- | Annotate the each value in the given traversable in IO.
283
368
noteEachIO :: (MonadTest m , MonadIO m , HasCallStack , Show a , Traversable f ) => IO (f a ) -> m (f a )
284
369
noteEachIO f = GHC. withFrozenCallStack $ do
285
370
! as <- H. evalIO f
286
371
for_ as $ noteWithCallstack GHC. callStack . show
287
372
return as
288
373
374
+ -- | Annotate the each value in the given traversable in IO, pretty printing it with indentation. Note that large data structures will take
375
+ -- a significant amount of vertical screen space.
376
+ noteEachPrettyIO :: (MonadTest m , MonadIO m , HasCallStack , Show a , Traversable f ) => IO (f a ) -> m (f a )
377
+ noteEachPrettyIO f = GHC. withFrozenCallStack $ do
378
+ ! as <- H. evalIO f
379
+ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
380
+ return as
381
+
289
382
-- | Annotate the each value in the given traversable in IO returning unit.
290
383
noteEachIO_ :: (MonadTest m , MonadIO m , HasCallStack , Show a , Traversable f ) => IO (f a ) -> m ()
291
384
noteEachIO_ f = GHC. withFrozenCallStack $ do
292
385
! as <- H. evalIO f
293
386
for_ as $ noteWithCallstack GHC. callStack . show
294
387
388
+ -- | Annotate the each value in the given traversable in IO returning unit, pretty printing it with indentation. Note that large data structures will take
389
+ -- a significant amount of vertical screen space.
390
+ noteEachPrettyIO_ :: (MonadTest m , MonadIO m , HasCallStack , Show a , Traversable f ) => IO (f a ) -> m ()
391
+ noteEachPrettyIO_ f = GHC. withFrozenCallStack $ do
392
+ ! as <- H. evalIO f
393
+ for_ as $ noteWithCallstack GHC. callStack . H. showPretty
394
+
295
395
-- | Return the test file path after annotating it relative to the project root directory
296
396
noteTempFile :: (MonadTest m , HasCallStack ) => FilePath -> FilePath -> m FilePath
297
397
noteTempFile tempDir filePath = GHC. withFrozenCallStack $ do
0 commit comments