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

purs-tidy format-in-place src test bench #228

Merged
merged 2 commits into from
Sep 30, 2024
Merged
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
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,3 @@ jobs:

- name: Check formatting
run: purs-tidy check src test bench

- name: Verify Bower & Pulp
run: |
npm install bower [email protected]
npx bower install
npx pulp build -- --censor-lib --strict
68 changes: 35 additions & 33 deletions test/Test/IndentationTests.purs
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@ testIndentationParser :: TestM
testIndentationParser = do
parseTest
( joinWith "\n"
[ "k \n"
, " a1 \n"
, " a2 \n"
, " b1 \n"
, " a3 \n"
, " haha \n"
, " it \n"
, " works \n"
, " "
]
[ "k \n"
, " a1 \n"
, " a2 \n"
, " b1 \n"
, " a3 \n"
, " haha \n"
, " it \n"
, " works \n"
, " "
]
)
( Taxonomy "k"
[ Taxonomy "a1" []
, Taxonomy "a2"
[ Taxonomy "b1" []
]
, Taxonomy "a3"
[ Taxonomy "haha" []
, Taxonomy "it" []
, Taxonomy "works" []
]
]
[ Taxonomy "a1" []
, Taxonomy "a2"
[ Taxonomy "b1" []
]
, Taxonomy "a3"
[ Taxonomy "haha" []
, Taxonomy "it" []
, Taxonomy "works" []
]
]
)
(pTaxonomy <* eof)

Expand All @@ -98,25 +98,27 @@ testIndentationParser = do
eof
pure { x, y, z }

parseErrorTestPositionAndMessage (do
x <- intDecimal
void $ string "\n "
indented *> withPos do
checkIndent -- This should pass.
y <- intDecimal
void $ string "\n"
indented *> withPos do -- indented should fail
z <- intDecimal
eof
pure { x, y, z }
parseErrorTestPositionAndMessage
( do
x <- intDecimal
void $ string "\n "
indented *> withPos do
checkIndent -- This should pass.
y <- intDecimal
void $ string "\n"
indented *> withPos do -- indented should fail
z <- intDecimal
eof
pure { x, y, z }
)
"111\n 222\n333"
"""not indented"""
(Position { column: 1, index: 10, line: 3 })

-- Testing function 'indentParens'
parseTest "(1,2,3)" (fromFoldable ["1", "2", "3"]) $
indentParens $ sepBy (string "1" <|> string "2" <|> string "3") (char ',')
parseTest "(1,2,3)" (fromFoldable [ "1", "2", "3" ])
$ indentParens
$ sepBy (string "1" <|> string "2" <|> string "3") (char ',')

-- doesnt work, dont understand idea of this method
-- parseTest """(\n 1,\n 2,\n 3)""" (fromFoldable ["1", "2", "3"]) $
Expand Down
2 changes: 1 addition & 1 deletion test/Test/Lib.purs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mkParseTest runParser input expected p = case runParser input p of
Right actual -> do
assert' ("expected output: " <> show expected <> ", actual output: " <> show actual) (expected == actual)
logShow actual
Left err -> assert' (joinWith "\n" $ ["error: " <> show err] <> parseErrorHuman__onlyString input 60 err) false
Left err -> assert' (joinWith "\n" $ [ "error: " <> show err ] <> parseErrorHuman__onlyString input 60 err) false

mkParseErrorTestPosition :: forall s a m. Show a => (s -> ParserT s m a -> Either ParseError a) -> ParserT s m a -> s -> Position -> Effect Unit
mkParseErrorTestPosition runParser p input expected = case runParser input p of
Expand Down
Loading