Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making it a bit easier to run individual tests in Doc.hs #5517

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions unison-syntax/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tests:
- easytest
- free
- megaparsec
- safe
- unison-core1
- unison-prelude
- unison-syntax
Expand Down
7 changes: 6 additions & 1 deletion unison-syntax/test/Unison/Test/Doc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module Unison.Test.Doc (test) where

import Control.Comonad.Trans.Cofree (CofreeF ((:<)))
import Data.Bifunctor (first)
import Data.Char (isAlphaNum)
import Data.List.NonEmpty (NonEmpty ((:|)))
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import EasyTest
import Text.Megaparsec qualified as P
Expand All @@ -12,6 +14,7 @@ import Unison.Syntax.Name qualified as Name
import Unison.Syntax.Parser.Doc qualified as DP
import Unison.Syntax.Parser.Doc.Data qualified as Doc
import Unison.Util.Recursion
import Safe (headMay)

test :: Test ()
test =
Expand Down Expand Up @@ -133,7 +136,7 @@ t ::
[Doc.Top String (Fix (Doc.Leaf Text String)) (Fix (Doc.Top String (Fix (Doc.Leaf Text String))))] ->
Test ()
t s expected =
scope s
scope simpleScope $ scope s
. either
(crash . P.errorBundlePretty)
( \actual ->
Expand All @@ -147,6 +150,8 @@ t s expected =
crash "actual != expected"
)
$ P.runParser (DP.doc (Name.toText . HQ'.toName . snd <$> typeOrTerm) (P.manyTill P.anySingle) P.eof) "test case" s
where
simpleScope = fromMaybe "default" $ headMay $ words $ filter isAlphaNum s
Comment on lines +153 to +154
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the issue is that some of the test names are not easy (and maybe not possible?) to provide at the command-line, due to weird stuff like newlines. And are there maybe tests with no name at all?

But could you add some comments to the code about what this line is trying to accomplish and why?


-- * Helper functions to make it easier to read the examples.

Expand Down
1 change: 1 addition & 0 deletions unison-syntax/unison-syntax.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ test-suite syntax-tests
, easytest
, free
, megaparsec
, safe
, text
, unison-core1
, unison-prelude
Expand Down
Loading