Skip to content

Commit 021e95c

Browse files
committed
PrettyParseTests: m refactor
1 parent a541bcc commit 021e95c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tests/NixLanguageTests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Nix.Pretty
2020
import Nix.String
2121
import Nix.XML
2222
import qualified Options.Applicative as Opts
23-
import System.Environment
23+
import System.Environment ( setEnv )
2424
import System.FilePath.Glob ( compile
2525
, globDir1
2626
)

tests/PrettyParseTests.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ normalize = foldFix $ \case
221221

222222
-- | Test that parse . pretty == id up to attribute position information.
223223
prop_prettyparse :: Monad m => NExpr -> PropertyT m ()
224-
prop_prettyparse p = do
225-
let prog = show $ prettyNix p
224+
prop_prettyparse p =
226225
either
227226
(\ s -> do
228227
footnote $ show $ vsep
@@ -263,6 +262,8 @@ prop_prettyparse p = do
263262
)
264263
(parse $ fromString prog)
265264
where
265+
prog = show $ prettyNix p
266+
266267
parse = parseNixText
267268

268269
normalise s = String.unlines $ reverse . dropWhile isSpace . reverse <$> String.lines s
@@ -271,6 +272,6 @@ prop_prettyparse p = do
271272
ldiff s1 s2 = getDiff ((: mempty) <$> String.lines s1) ((: mempty) <$> String.lines s2)
272273

273274
tests :: TestLimit -> TestTree
274-
tests n = testProperty "Pretty/Parse Property" $ withTests n $ property $ do
275-
x <- forAll genExpr
276-
prop_prettyparse x
275+
tests n =
276+
testProperty "Pretty/Parse Property" $
277+
withTests n $ property $ prop_prettyparse =<< forAll genExpr

0 commit comments

Comments
 (0)