on master help sign in
count scalars test
commit5b5ad3f59e6db056e51f44dadbf726793b07eb26 authorMichael Snoyman <michael@snoyman.com> dateTue 12 Jan 2010, 12:55 (17 years ago) parentb11333d
2 files changed+27−3
runtests.hs+23−2 yaml.cabal+4−1
runtests.hs+23−2
@@ -1,8 +1,29 @@
11import Test.Framework (defaultMain)
22
3−import qualified Data.Object.Yaml
3+import Text.Libyaml
4+import qualified Data.ByteString.Char8 as B8
5+
6+--import Test.Framework (testGroup, Test)
7+import Test.Framework.Providers.HUnit
8+--import Test.Framework.Providers.QuickCheck (testProperty)
9+import Test.HUnit hiding (Test, path)
10+--import Test.QuickCheck
411
512main :: IO ()
613main = defaultMain
7− [ Data.Object.Yaml.testSuite
14+ [ testCase "count scalars" caseCountScalars
815 ]
16+
17+caseCountScalars :: Assertion
18+caseCountScalars = do
19+ Right res <- decode yamlBS fold accum
20+ res @?= (7, 1, 2)
21+ where
22+ yamlString = "foo:\n baz: [bin1, bin2, bin3]\nbaz: bazval"
23+ yamlBS = B8.pack yamlString
24+ fold (s, l, m) (EventScalar {}) = Right (s + 1, l, m)
25+ fold (s, l, m) EventSequenceStart = Right (s, l + 1, m)
26+ fold (s, l, m) EventMappingStart = Right (s, l, m + 1)
27+ fold res EventNone = Left res
28+ fold res _ = Right res
29+ accum = (0, 0, 0) :: (Int, Int, Int)
yaml.cabal+4−1
@@ -51,7 +51,10 @@ executable runtests
5151 test-framework-quickcheck,
5252 test-framework-hunit,
5353 HUnit,
54− QuickCheck >= 1 && < 2
54+ QuickCheck >= 1 && < 2,
55+ base >= 4 && < 5,
56+ bytestring >= 0.9.1.4 && < 0.10,
57+ failure >= 0.0.0 && < 0.1
5558 else
5659 Buildable: False
5760 ghc-options: -Wall