mirror of
https://github.com/tweag/ormolu.git
synced 2024-09-11 13:16:13 +03:00
Replace “idempotency” with “idempotence”
This commit is contained in:
parent
bc621311dd
commit
5d1612f153
@ -3,6 +3,9 @@
|
||||
* Fixed rendering of type signatures concerning several identifiers. [Issue
|
||||
566](https://github.com/tweag/ormolu/issues/566).
|
||||
|
||||
* Renamed the `--check-idempotency` flag to `--check-idempotence`.
|
||||
Apparently only the latter is correct.
|
||||
|
||||
## Ormolu 0.0.5.0
|
||||
|
||||
* Grouping of statements in `do`-blocks is now preserved. [Issue
|
||||
|
@ -30,7 +30,7 @@ Testing is performed as following:
|
||||
* The result of printing is parsed back again and the AST is compared to the
|
||||
AST obtained from the original file. They should match.
|
||||
* The output of printer is checked against the expected output.
|
||||
* Idempotency property is verified: formatting already formatted code
|
||||
* Idempotence property is verified: formatting already formatted code
|
||||
results in exactly the same output.
|
||||
|
||||
Examples can be organized in sub-directories, see the existing ones for
|
||||
|
@ -167,7 +167,7 @@ configParser =
|
||||
help "Output information useful for debugging"
|
||||
]
|
||||
<*> (switch . mconcat)
|
||||
[ long "check-idempotency",
|
||||
[ long "check-idempotence",
|
||||
short 'c',
|
||||
help "Fail if formatting is not idempotent"
|
||||
]
|
||||
|
14
default.nix
14
default.nix
@ -131,19 +131,19 @@ in {
|
||||
doCheck = true;
|
||||
buildPhase = ''
|
||||
cp src.hs result-all-implicit.hs
|
||||
ormolu --check-idempotency --mode inplace result-all-implicit.hs
|
||||
ormolu --check-idempotence --mode inplace result-all-implicit.hs
|
||||
cp src.hs result-all-explicit.hs
|
||||
ormolu --check-idempotency --mode inplace --start-line 1 --end-line 13 result-all-explicit.hs
|
||||
ormolu --check-idempotence --mode inplace --start-line 1 --end-line 13 result-all-explicit.hs
|
||||
cp src.hs result-only-start.hs
|
||||
ormolu --check-idempotency --mode inplace --start-line 1 result-only-start.hs
|
||||
ormolu --check-idempotence --mode inplace --start-line 1 result-only-start.hs
|
||||
cp src.hs result-only-end.hs
|
||||
ormolu --check-idempotency --mode inplace --end-line 13 result-only-end.hs
|
||||
ormolu --check-idempotence --mode inplace --end-line 13 result-only-end.hs
|
||||
cp src.hs result-6-7.hs
|
||||
ormolu --check-idempotency --mode inplace --start-line 6 --end-line 7 result-6-7.hs
|
||||
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 7 result-6-7.hs
|
||||
cp src.hs result-6-8.hs
|
||||
ormolu --check-idempotency --mode inplace --start-line 6 --end-line 8 result-6-8.hs
|
||||
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 8 result-6-8.hs
|
||||
cp src.hs result-9-13.hs
|
||||
ormolu --check-idempotency --mode inplace --start-line 9 --end-line 13 result-9-13.hs
|
||||
ormolu --check-idempotence --mode inplace --start-line 9 --end-line 13 result-9-13.hs
|
||||
'';
|
||||
checkPhase = ''
|
||||
echo result-all-implicit.hs
|
||||
|
@ -32,7 +32,7 @@
|
||||
cp "$hs_file" "''${hs_file}-original"
|
||||
done
|
||||
|
||||
(ormolu --check-idempotency --mode inplace $hs_files || true) 2> log.txt
|
||||
(ormolu --check-idempotence --mode inplace $hs_files || true) 2> log.txt
|
||||
'';
|
||||
inherit doCheck;
|
||||
checkPhase =
|
||||
|
@ -63,7 +63,7 @@ ormolu cfgWithIndices path str = do
|
||||
-- to parse the rendered code back, inside of GHC monad wrapper which will
|
||||
-- lead to error messages presenting the exceptions as GHC bugs.
|
||||
let !txt = printModule result0
|
||||
when (not (cfgUnsafe cfg) || cfgCheckIdempotency cfg) $ do
|
||||
when (not (cfgUnsafe cfg) || cfgCheckIdempotence cfg) $ do
|
||||
let pathRendered = path ++ "<rendered>"
|
||||
-- Parse the result of pretty-printing again and make sure that AST
|
||||
-- is the same as AST of original snippet module span positions.
|
||||
@ -79,7 +79,7 @@ ormolu cfgWithIndices path str = do
|
||||
Different ss -> liftIO $ throwIO (OrmoluASTDiffers path ss)
|
||||
-- Try re-formatting the formatted result to check if we get exactly
|
||||
-- the same output.
|
||||
when (cfgCheckIdempotency cfg) $
|
||||
when (cfgCheckIdempotence cfg) $
|
||||
let txt2 = printModule result1
|
||||
in case diffText txt txt2 pathRendered of
|
||||
Nothing -> return ()
|
||||
|
@ -24,7 +24,7 @@ data Config region = Config
|
||||
-- | Output information useful for debugging
|
||||
cfgDebug :: !Bool,
|
||||
-- | Checks if re-formatting the result is idempotent
|
||||
cfgCheckIdempotency :: !Bool,
|
||||
cfgCheckIdempotence :: !Bool,
|
||||
-- | Region selection
|
||||
cfgRegion :: !region
|
||||
}
|
||||
@ -56,7 +56,7 @@ defaultConfig =
|
||||
{ cfgDynOptions = [],
|
||||
cfgUnsafe = False,
|
||||
cfgDebug = False,
|
||||
cfgCheckIdempotency = False,
|
||||
cfgCheckIdempotence = False,
|
||||
cfgRegion =
|
||||
RegionIndices
|
||||
{ regionStartLine = Nothing,
|
||||
|
@ -62,7 +62,7 @@ deriveOutput path =
|
||||
-- | A version of 'shouldBe' that is specialized to comparing 'Text' values.
|
||||
-- It also prints multi-line snippets in a more readable form.
|
||||
shouldMatch :: Bool -> Text -> Text -> Expectation
|
||||
shouldMatch idempotencyTest actual expected =
|
||||
shouldMatch idempotenceTest actual expected =
|
||||
when (actual /= expected) . expectationFailure $
|
||||
unlines
|
||||
[ ">>>>>>>>>>>>>>>>>>>>>> expected (" ++ pass ++ "):",
|
||||
@ -72,8 +72,8 @@ shouldMatch idempotencyTest actual expected =
|
||||
]
|
||||
where
|
||||
pass =
|
||||
if idempotencyTest
|
||||
then "idempotency pass"
|
||||
if idempotenceTest
|
||||
then "idempotence pass"
|
||||
else "first pass"
|
||||
|
||||
examplesDir :: Path Rel Dir
|
||||
|
Loading…
Reference in New Issue
Block a user