From 2a61f99f00f550c9f09b60d9a350c3f6627a450a Mon Sep 17 00:00:00 2001 From: James Brock Date: Mon, 30 Sep 2024 13:39:05 +0900 Subject: [PATCH] purs-tidy format-in-place src test bench --- test/Test/IndentationTests.purs | 68 +++++++++++++++++---------------- test/Test/Lib.purs | 2 +- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/test/Test/IndentationTests.purs b/test/Test/IndentationTests.purs index 6e0592b..d886c40 100644 --- a/test/Test/IndentationTests.purs +++ b/test/Test/IndentationTests.purs @@ -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) @@ -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"]) $ diff --git a/test/Test/Lib.purs b/test/Test/Lib.purs index 91aad88..79e719d 100644 --- a/test/Test/Lib.purs +++ b/test/Test/Lib.purs @@ -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