packages feed

lens-toml-parser 0.3.0.0 → 0.3.0.1

raw patch · 3 files changed

+44/−39 lines, 3 filesdep ~dwergazPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: dwergaz

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -33,3 +33,8 @@   new toml-parser using Text and different constructor names. It also   adds new prisms supporting annotations used by the new toml-parser   version for tracking file locations.++## 0.3.0.1  -- 2024-12-05++* Updated to dwergaz >=3.0.+* Tweaked tests.
lens-toml-parser.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                lens-toml-parser-version:             0.3.0.0+version:             0.3.0.1 synopsis:            Lenses for toml-parser description:         This library provides lenses for toml-parser. license:             ISC@@ -14,7 +14,7 @@ category:            Language, Lenses build-type:          Simple cabal-version:       >=1.10-tested-with:         GHC ==9.4.8 || ==9.6.4 || ==9.8.2+tested-with:         GHC ==9.4.8 || ==9.6.6 || ==9.8.2  extra-source-files:   .gitignore@@ -44,7 +44,7 @@   main-is:             Main.hs   build-depends:       base        >=4.14 && <5                      , containers  >=0.5  && <0.8-                     , dwergaz     >=0.2  && <0.3+                     , dwergaz     >=0.3  && <0.4                      , lens-family >=2.1  && <2.2                      , text        >=0.2  && <3                      , toml-parser >=2.0  && <2.1
test/Main.hs view
@@ -42,9 +42,8 @@  testTableKey :: Table -> Test testTableKey kv =-  Expect+  assertEqual     "'key' from 'table' == Just \"value\""-    (==)     expected     actual   where@@ -53,9 +52,8 @@  testTableZoo :: Table -> Test testTableZoo kv =-  Expect+  assertEqual     "'zoo' from 'table' == Nothing"-    (==)     expected     actual   where@@ -64,9 +62,8 @@  testTableSubtableKey :: Table -> Test testTableSubtableKey kv =-  Expect+  assertEqual     "'key' from 'subtable' from 'table' == Just \"another value\""-    (==)     expected     actual   where@@ -75,9 +72,8 @@  testTableInlineNameFirst :: Table -> Test testTableInlineNameFirst kv =-  Expect+  assertEqual     "'first' from 'name' from 'inline' from 'table' == \"Tom\""-    (==)     expected     actual   where@@ -86,9 +82,8 @@  testTableInlinePointY :: Table -> Test testTableInlinePointY kv =-  Expect+  assertEqual     "'y' from 'point' from 'inline' from 'table' == Just 2"-    (==)     expected     actual   where@@ -97,9 +92,8 @@  testStringBasicBasic :: Table -> Test testStringBasicBasic kv =-  Expect+  assertEqual     "'basic' from 'basic' from 'string' == <some escaped nonsense>"-    (==)     expected     actual   where@@ -108,10 +102,9 @@  testStringMultiline :: Table -> Test testStringMultiline kv =-  Predicate+  assertBool     "'key1', 'key2', and 'key3' from 'multiline' from 'string' are all the same"-    allEqual-    [actual1, actual2, actual3]+    (allEqual [actual1, actual2, actual3])   where     actual1 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key1" . _Text     actual2 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key2" . _Text@@ -119,10 +112,9 @@  testStringMultilineContinued :: Table -> Test testStringMultilineContinued kv =-  Predicate+  assertBool     "'key1', 'key2', and 'key3' from 'continued' from 'multiline' from 'string' are all the same"-    allEqual-    [actual1, actual2, actual3]+    (allEqual [actual1, actual2, actual3])   where     actual1 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key1" . _Text     actual2 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key2" . _Text@@ -130,29 +122,37 @@  testArrayKey1 :: Table -> Test testArrayKey1 kv =-  Expect+  assertEqual     "'key1' from 'array' == [1, 2, 3]"-    (==)     expected     actual   where     expected = [1, 2, 3]     actual = kv ^.. mapAt "array" . valueAt "key1" . _List . traverse . _Integer -runTests :: Table -> [Result]-runTests kv = runTest . ($ kv) <$> tests+tests :: [Table -> Test]+tests =+  [ testTableKey,+    testTableZoo,+    testTableSubtableKey,+    testTableInlineNameFirst,+    testTableInlinePointY,+    testStringBasicBasic,+    testStringMultiline,+    testStringMultilineContinued,+    testArrayKey1+  ]++step :: Result -> (ShowS, Bool) -> (ShowS, Bool)+step result (f, allPassed) =+  ( showString (resultToString result) . showChar '\n' . f,+    resultIsPassed result && allPassed+  )++runTests :: Table -> (String, Bool)+runTests kv = (buildString mempty, passed)   where-    tests =-      [ testTableKey,-        testTableZoo,-        testTableSubtableKey,-        testTableInlineNameFirst,-        testTableInlinePointY,-        testStringBasicBasic,-        testStringMultiline,-        testStringMultilineContinued,-        testArrayKey1-      ]+    (buildString, passed) = foldr (step . runTest . ($ kv)) (mempty, True) tests  readTomlFile :: String -> IO Table readTomlFile file = TIO.readFile file >>= parse >>= handleError@@ -163,6 +163,6 @@ main :: IO () main = do   ex <- readTomlFile "./example/example-v0.4.0.toml"-  let rs = runTests ex-  mapM_ print rs-  unless (all isPassed rs) exitFailure+  let (output, passed) = runTests ex+  putStr output+  unless passed exitFailure