aboutsummaryrefslogtreecommitdiff
path: root/js/test
diff options
context:
space:
mode:
Diffstat (limited to 'js/test')
-rw-r--r--js/test/Main.purs61
1 files changed, 0 insertions, 61 deletions
diff --git a/js/test/Main.purs b/js/test/Main.purs
deleted file mode 100644
index 3a4f03c..0000000
--- a/js/test/Main.purs
+++ /dev/null
@@ -1,61 +0,0 @@
-module Test.Main
- ( main
- ) where
-
-import Data.Maybe (Maybe(Just, Nothing))
-import Effect (Effect)
-import Prelude
-import Test.Spec (describe, it)
-import Test.Spec.Assertions (shouldEqual)
-import Test.Spec.Reporter.Console (consoleReporter)
-import Test.Spec.Runner (run)
-
-import Number (roundAt, format) as Number
-import Parser (TextWithNumber)
-import Parser (textWithNumber, number) as Parser
-
-main :: Effect Unit
-main = run [consoleReporter] do
-
- describe "Number" do
- it "rounds numbers" $ do
- (Number.roundAt 0 0.0) `shouldEqual` (0.0)
- (Number.roundAt 5 0.0) `shouldEqual` (0.0)
- (Number.roundAt 0 12.3456) `shouldEqual` (12.0)
- (Number.roundAt 1 12.3456) `shouldEqual` (12.3)
- (Number.roundAt 2 12.3456) `shouldEqual` (12.35)
- (Number.roundAt 3 12.3456) `shouldEqual` (12.346)
- (Number.roundAt 4 12.3456) `shouldEqual` (12.3456)
- (Number.roundAt 5 12.3456) `shouldEqual` (12.3456)
-
- it "formats numbers" $ do
- (Number.format 0.0) `shouldEqual` "0"
- (Number.format 0.1) `shouldEqual` "0,1"
- (Number.format 12.3456) `shouldEqual` "12,3"
- (Number.format 12.9) `shouldEqual` "12,9"
- (Number.format 12.99) `shouldEqual` "13,0"
- (Number.format 123456.0) `shouldEqual` "123456"
- (Number.format 1234.5678) `shouldEqual` "1234,6"
-
- describe "Parser" do
- it "parses number" $ do
- (Parser.number "") `shouldEqual` Nothing
- (Parser.number "auie") `shouldEqual` Nothing
- (Parser.number "13.8auie") `shouldEqual` Nothing
- (Parser.number "13.") `shouldEqual` Nothing
- (Parser.number ".8") `shouldEqual` Nothing
- (Parser.number "13") `shouldEqual` (Just 13.0)
- (Parser.number "13,8") `shouldEqual` (Just 13.8)
- (Parser.number "13.8") `shouldEqual` (Just 13.8)
- (Parser.number "123 456") `shouldEqual` Nothing
-
- it "parses textWithNumber" $ do
- map showTwn (Parser.textWithNumber "") `shouldEqual` Nothing
- map showTwn (Parser.textWithNumber "0") `shouldEqual` Just (showTwn { begin: "", number: 0.0, end: "" })
- map showTwn (Parser.textWithNumber "13,8") `shouldEqual` Just (showTwn { begin: "", number: 13.8, end: "" })
- map showTwn (Parser.textWithNumber "begin 0 end") `shouldEqual` Just (showTwn { begin: "begin ", number: 0.0, end: " end" })
- map showTwn (Parser.textWithNumber "14end") `shouldEqual` Just (showTwn { begin: "", number: 14.0, end: "end" })
- map showTwn (Parser.textWithNumber "begin14") `shouldEqual` Just (showTwn { begin: "begin", number: 14.0, end: "" })
-
-showTwn :: TextWithNumber -> String
-showTwn { begin, number, end } = begin <> show number <> end