Fix eval-okay-builtins-add.

Nix omits the trailing .0 when displaying a Float. Aligning current
hnix pretty printer with this behaviour.

Fixes #447.
This commit is contained in:
Félix Baylac-Jacqué 2019-03-22 22:50:29 +01:00 committed by John Wiegley
parent 4607639774
commit 3acc67ba66
2 changed files with 6 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import Codec.Serialise
#endif
import Control.DeepSeq
import Data.Data
import Data.Fixed (mod')
import Data.Hashable
import Data.Text ( Text
, pack
@ -40,6 +41,10 @@ instance Serialise NAtom
-- | Translate an atom into its nix representation.
atomText :: NAtom -> Text
atomText (NInt i) = pack (show i)
atomText (NFloat f) = pack (show f)
atomText (NFloat f) = pack (showNixFloat f)
where
showNixFloat x
| x `mod'` 1 /= 0 = show x
| otherwise = show (truncate x :: Int)
atomText (NBool b) = if b then "true" else "false"
atomText NNull = "null"

View File

@ -71,7 +71,6 @@ newFailingTests = Set.fromList
, "eval-okay-fromTOML"
, "eval-okay-context-introspection"
, "eval-okay-concatmap"
, "eval-okay-builtins-add"
]
genTests :: IO TestTree