aboutsummaryrefslogtreecommitdiff
path: root/test/Main.purs
blob: 5ebbb035681c4b83075a1081338e2132cbf1b738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Test.Main where

import Prelude
import Control.Monad.Aff (later')
import Control.Monad.Eff (Eff)
import Test.Spec (describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (RunnerEffects, run)

import Format as Format

main :: Eff (RunnerEffects ()) Unit
main = run [consoleReporter] do

  describe "Format" do
    it "format numbers" $ do
      (Format.number 0 0.0) `shouldEqual` "0"
      (Format.number 0 (-0.0)) `shouldEqual` "0"
      (Format.number 0 8.0) `shouldEqual` "8"
      (Format.number 0 (-4.0)) `shouldEqual` "-4"
      (Format.number 2 25.0) `shouldEqual` "25,00"
      (Format.number 5 25.0) `shouldEqual` "25,00000"
      (Format.number 5 25.13) `shouldEqual` "25,13000"
      (Format.number 1 25.13) `shouldEqual` "25,1"
      (Format.number 1 25.15) `shouldEqual` "25,1"
      (Format.number 1 25.19) `shouldEqual` "25,2"