Skip to content

Commit

Permalink
Update formatting with the new version of Ormolu.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamirTalwar committed Sep 24, 2024
1 parent e08d363 commit 9bb6c4e
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/app/Test/Smoke/App/PrintResults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ printFailingInput value =
putRed $ fromString $ indentedKey (" " ++ unFixtureName (fixtureName @a) ++ ":")
putPlainLn $ indented outputIndentation (serializeFixture v)

printFailingOutput :: forall a. FromFixture a => AssertionResult a -> Output ()
printFailingOutput :: forall a. (FromFixture a) => AssertionResult a -> Output ()
printFailingOutput = printFailures (ShortName (unFixtureName (fixtureName @a)))

printFailingFilesOutput ::
Expand All @@ -58,10 +58,10 @@ printFailingFilesOutput fileResults =
putRedLn " files:"
forM_ (Map.assocs fileResults) $ uncurry printFailingFileOutput

printFailingFileOutput :: FromFixture a => Path Relative File -> AssertionResult a -> Output ()
printFailingFileOutput :: (FromFixture a) => Path Relative File -> AssertionResult a -> Output ()
printFailingFileOutput path = printFailures (LongName (" " ++ toFilePath path))

printFailures :: FromFixture a => PartName -> AssertionResult a -> Output ()
printFailures :: (FromFixture a) => PartName -> AssertionResult a -> Output ()
printFailures _ AssertionSuccess =
pure ()
printFailures name (AssertionFailure (SingleAssertionFailure failure)) = do
Expand Down Expand Up @@ -92,7 +92,7 @@ failureIsInline AssertionFailureContains {} = False
failureIsInline AssertionFailureExpectedFileError {} = True
failureIsInline AssertionFailureActualFileError {} = True

printFailure :: FromFixture a => AssertionFailure a -> Output ()
printFailure :: (FromFixture a) => AssertionFailure a -> Output ()
printFailure (AssertionFailureDiff (Expected expected) (Actual actual)) =
printDiff (serializeFixture expected) (serializeFixture actual)
printFailure (AssertionFailureContains (Expected expected) (Actual actual)) = do
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ processOutputs location (TestPlan _ _ fallbackShell _ _ _ _ expectedStatus expec
expectedFiles
pure $ FinishedTest statusResult stdOutResult stdErrResult fileResults
where
assertEqual :: Eq a => a -> a -> EqualityResult a
assertEqual :: (Eq a) => a -> a -> EqualityResult a
assertEqual expected actual
| expected == actual = EqualitySuccess
| otherwise = EqualityFailure (Expected expected) (Actual actual)
Expand Down Expand Up @@ -77,5 +77,5 @@ ifEmpty x xs
| Vector.null xs = Vector.singleton x
| otherwise = xs

defaultIfEmpty :: Default a => Vector a -> Vector a
defaultIfEmpty :: (Default a) => Vector a -> Vector a
defaultIfEmpty = ifEmpty def
6 changes: 3 additions & 3 deletions src/lib/Test/Smoke/Bless.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ blessFinishedTest location testPlan@(TestPlan {planTest = test}) result@(Finishe
writeToPath (location </> path) text
pure $ makeAfter AssertionSuccess before

serialize :: forall a. FromFixture a => Vector (TestOutput a) -> AssertionResult a -> IO (Maybe (Path Relative File, Text))
serialize :: forall a. (FromFixture a) => Vector (TestOutput a) -> AssertionResult a -> IO (Maybe (Path Relative File, Text))
serialize _ AssertionSuccess =
pure Nothing
serialize outputs (AssertionFailure result) =
Expand All @@ -61,7 +61,7 @@ serialize outputs (AssertionFailure result) =
_ ->
throwIO $ CouldNotBlessWithMultipleValues (fixtureName @a)

serializeFailure :: forall a. FromFixture a => TestOutput a -> AssertionFailures a -> IO (Maybe (Path Relative File, Text))
serializeFailure :: forall a. (FromFixture a) => TestOutput a -> AssertionFailures a -> IO (Maybe (Path Relative File, Text))
serializeFailure (TestOutputFromFile _ path) (SingleAssertionFailure (AssertionFailureDiff _ (Actual actual))) =
pure $ Just (path, serializeFixture actual)
serializeFailure _ (SingleAssertionFailure (AssertionFailureDiff _ (Actual actual))) =
Expand All @@ -77,5 +77,5 @@ serializeFailure _ (SingleAssertionFailure (AssertionFailureActualFileError _))
serializeFailure _ (MultipleAssertionFailures _) =
throwIO $ CouldNotBlessWithMultipleValues (fixtureName @a)

failed :: Applicative f => Test -> SmokeBlessError -> f TestResult
failed :: (Applicative f) => Test -> SmokeBlessError -> f TestResult
failed test = pure . TestErrored test . BlessError
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
runExceptTIO :: (Exception e, MonadIO m) => ExceptT e m a -> m a
runExceptTIO = either (liftIO . throwIO) pure <=< runExceptT

onNothingThrow :: Monad m => e -> Maybe a -> ExceptT e m a
onNothingThrow :: (Monad m) => e -> Maybe a -> ExceptT e m a
onNothingThrow exception = maybe (throwE exception) pure

onNothingThrow_ :: Monad m => e -> Maybe a -> ExceptT e m ()
onNothingThrow_ :: (Monad m) => e -> Maybe a -> ExceptT e m ()
onNothingThrow_ exception = (>> pure ()) . onNothingThrow exception

handleError :: (a -> b) -> Either a b -> b
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Test/Smoke/Plan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ readTestOutput _ (TestOutputInline assertion) =
readTestOutput location (TestOutputFromFile constructor contents) =
liftIO $ either AssertFileError constructor <$> runExceptT (readPath location contents)

readPath :: ToFixture a => Path Resolved Dir -> Path Relative File -> ExceptT SmokeFileError IO a
readPath :: (ToFixture a) => Path Resolved Dir -> Path Relative File -> ExceptT SmokeFileError IO a
readPath location path =
deserializeFixture
<$> withExceptT
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Types/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Test.Smoke.Types.Errors
import Test.Smoke.Types.Filters

data Assert a where
AssertEquals :: Eq a => a -> Assert a
AssertContains :: FromFixture a => Text -> Assert a
AssertEquals :: (Eq a) => a -> Assert a
AssertContains :: (FromFixture a) => Text -> Assert a
AssertFiltered :: (FromFixture a, ToFixture a) => Filter -> Assert a -> Assert a
AssertFileError :: SmokeFileError -> Assert a

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Test/Smoke/Types/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class FromFixture a where
fixtureName :: FixtureName
serializeFixture :: a -> Text

parseFixtureJSON :: ToFixture a => String -> Value -> Parser a
parseFixtureJSON :: (ToFixture a) => String -> Value -> Parser a
parseFixtureJSON name = withText name (return . deserializeFixture)

instance ToFixture Text where
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Test/Smoke/Types/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ instance FromJSON TestFile where

newtype Many a = Many {unMany :: Vector a}

instance FromJSON a => FromJSON (Many a) where
instance (FromJSON a) => FromJSON (Many a) where
parseJSON a@(Array _) = Many <$> parseJSON a
parseJSON v = Many . Vector.singleton <$> parseJSON v

manyMaybe :: FromJSON a => Maybe (Many a) -> Vector a
manyMaybe :: (FromJSON a) => Maybe (Many a) -> Vector a
manyMaybe Nothing = Vector.empty
manyMaybe (Just v) = unMany v
6 changes: 3 additions & 3 deletions src/lib/Test/Smoke/Types/Values.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data TestInput a where
TestInputFromFile :: Path Relative File -> TestInput a
TestInputFiltered :: TestInput a -> Filter -> TestInput a

instance FromJSON a => FromJSON (TestInput a) where
instance (FromJSON a) => FromJSON (TestInput a) where
parseJSON value = do
(inner, contentFilter) <- parseContentsOrFile value
let testInput = case inner of
Expand All @@ -27,7 +27,7 @@ instance FromJSON a => FromJSON (TestInput a) where

data TestOutput actual where
TestOutputInline :: Assert actual -> TestOutput actual
TestOutputFromFile :: ToFixture expected => (expected -> Assert actual) -> Path Relative File -> TestOutput actual
TestOutputFromFile :: (ToFixture expected) => (expected -> Assert actual) -> Path Relative File -> TestOutput actual

instance (Eq actual, ToFixture actual, FromFixture actual, FromJSON actual) => FromJSON (TestOutput actual) where
parseJSON value@(Object v) =
Expand Down Expand Up @@ -59,7 +59,7 @@ parseTestOutput assertion value = do
where
filteredAssertion fixtureFilter expected = AssertFiltered fixtureFilter (assertion expected)

parseContentsOrFile :: FromJSON a => Value -> Parser (Either a (Path Relative File), Maybe Filter)
parseContentsOrFile :: (FromJSON a) => Value -> Parser (Either a (Path Relative File), Maybe Filter)
parseContentsOrFile s@(String _) = do
contents <- parseJSON s
pure (Left contents, Nothing)
Expand Down

0 comments on commit 9bb6c4e

Please sign in to comment.