packages feed

terminal-progress-bar 0.0.1 → 0.0.1.1

raw patch · 2 files changed

+74/−5 lines, 2 filesdep ~basedep ~terminal-progress-bardep ~test-framework

Dependency ranges changed: base, terminal-progress-bar, test-framework

Files

terminal-progress-bar.cabal view
@@ -1,5 +1,5 @@ name:          terminal-progress-bar-version:       0.0.1+version:       0.0.1.1 cabal-version: >=1.8 build-type:    Simple stability:     provisional@@ -41,7 +41,7 @@  library     hs-source-dirs: src-    build-depends: base                 >= 3.0.3.1 && < 4.6+    build-depends: base                 >= 3.0.3.1 && < 4.7                  , base-unicode-symbols >= 0.2.2.3 && < 0.3     exposed-modules: System.ProgressBar     ghc-options: -Wall@@ -51,11 +51,11 @@   main-is: test.hs   hs-source-dirs: test   ghc-options: -Wall-  build-depends: base                  >= 3.0.3.1 && < 4.6+  build-depends: base                  >= 3.0.3.1 && < 4.7                , base-unicode-symbols  >= 0.2.2.3 && < 0.3                , HUnit                 >= 1.2.4.2 && < 1.3-               , terminal-progress-bar == 0.0.1-               , test-framework        >= 0.3.3   && < 0.5+               , terminal-progress-bar == 0.0.1.1+               , test-framework        >= 0.3.3   && < 0.7                , test-framework-hunit  >= 0.2.6   && < 0.3  -- executable example
+ test/test.hs view
@@ -0,0 +1,69 @@+{-# LANGUAGE NoImplicitPrelude, PackageImports, UnicodeSyntax #-}++module Main where+++--------------------------------------------------------------------------------+-- Imports+--------------------------------------------------------------------------------++import "base" Control.Monad      ( (=<<) )+import "base" Data.Function      ( ($) )+import "base" Prelude            ( String )+import "base" System.Environment ( getArgs )+import "base" System.IO          ( IO )+import "base-unicode-symbols" Prelude.Unicode ( ℤ )+import "HUnit" Test.HUnit.Base ( assertEqual )+import "test-framework" Test.Framework+    ( defaultMainWithOpts, interpretArgsOrExit, Test, testGroup )+import "test-framework-hunit" Test.Framework.Providers.HUnit ( testCase )+import "terminal-progress-bar" System.ProgressBar+    ( mkProgressBar, Label, noLabel, msg, percentage, exact )++--------------------------------------------------------------------------------+-- Test suite+--------------------------------------------------------------------------------++main ∷ IO ()+main = do opts ← interpretArgsOrExit =<< getArgs+          defaultMainWithOpts tests opts++tests ∷ [Test]+tests =+  [ testGroup "Label padding"+    [ eqTest "no labels"  "[]"          noLabel     noLabel      0 0 0+    , eqTest "pre"        "pre []"      (msg "pre") noLabel      0 0 0+    , eqTest "post"       "[] post"     noLabel     (msg "post") 0 0 0+    , eqTest "pre & post" "pre [] post" (msg "pre") (msg "post") 0 0 0+    ]+  , testGroup "Bar fill"+    [ eqTest "empty"       "[....]" noLabel noLabel 6  0   1+    , eqTest "almost half" "[=>..]" noLabel noLabel 6 49 100+    , eqTest "half"        "[==>.]" noLabel noLabel 6  1   2+    , eqTest "almost full" "[===>]" noLabel noLabel 6 99 100+    , eqTest "full"        "[====]" noLabel noLabel 6  1   1+    , eqTest "overfull"    "[====]" noLabel noLabel 6  2   1+    ]+  , testGroup "Labels"+    [ testGroup "Percentage"+      [ eqTest "  0%" "  0% [....]" percentage noLabel 11 0 1+      , eqTest "100%" "100% [====]" percentage noLabel 11 1 1+      , eqTest " 50%" " 50% [==>.]" percentage noLabel 11 1 2+      , eqTest "200%" "200% [====]" percentage noLabel 11 2 1+      ]+    , testGroup "Exact"+      [ eqTest "0/0" "0/0 [....]" exact noLabel 10 0 0+      , eqTest "1/1" "1/1 [====]" exact noLabel 10 1 1+      , eqTest "1/2" "1/2 [==>.]" exact noLabel 10 1 2+      , eqTest "2/1" "2/1 [====]" exact noLabel 10 2 1+      ]+    ]+  ]++eqTest ∷ String → String → Label → Label → ℤ → ℤ → ℤ → Test+eqTest name expected mkPreLabel mkPostLabel width todo done =+    testCase name $ assertEqual errMsg expected actual+  where+    actual = mkProgressBar mkPreLabel mkPostLabel width todo done+    errMsg = "Expected result doesn't match actual result"+