Skip to content

Instantly share code, notes, and snippets.

@DigitalBrains1
Created January 29, 2022 11:12
Show Gist options
  • Select an option

  • Save DigitalBrains1/b9ff10af0379f061d059e8c733b9e8e5 to your computer and use it in GitHub Desktop.

Select an option

Save DigitalBrains1/b9ff10af0379f061d059e8c733b9e8e5 to your computer and use it in GitHub Desktop.

Revisions

  1. DigitalBrains1 created this gist Jan 29, 2022.
    47 changes: 47 additions & 0 deletions DocTest.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    module DocTest where

    -- | Problematic doctest example 1
    --
    -- >>> x = 1
    -- >>> :{
    -- x
    -- :}
    -- 1
    -- >>> x
    -- 1
    f :: Int
    f = 1

    -- | Problematic doctest example 2
    --
    -- >>> :{
    -- x = 1
    -- :}
    -- >>> x
    -- 1
    g :: Int
    g = 1

    -- | Working doctest example 1
    --
    -- >>> x = 1
    -- >>> :{
    -- x
    -- :}
    -- 1
    --
    -- >>> x
    -- 1
    h :: Int
    h = 1

    -- | Working doctest example 2
    --
    -- >>> :{
    -- x = 1
    -- :}
    --
    -- >>> x
    -- 1
    j :: Int
    j = 1
    15 changes: 15 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    [...]/DocTest.hs:6: failure in expression `:{
    x
    :}'
    expected: 1
    >>> x
    1
    but got: 1
    ^

    [...]/DocTest.hs:17: failure in expression `:{
    x = 1
    :}'
    expected: >>> x
    1
    but got: ^