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 #endif
import Control.DeepSeq import Control.DeepSeq
import Data.Data import Data.Data
import Data.Fixed (mod')
import Data.Hashable import Data.Hashable
import Data.Text ( Text import Data.Text ( Text
, pack , pack
@ -40,6 +41,10 @@ instance Serialise NAtom
-- | Translate an atom into its nix representation. -- | Translate an atom into its nix representation.
atomText :: NAtom -> Text atomText :: NAtom -> Text
atomText (NInt i) = pack (show i) 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 (NBool b) = if b then "true" else "false"
atomText NNull = "null" atomText NNull = "null"

View file

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