Skip to content

Commit

Permalink
use dwergaz from git
Browse files Browse the repository at this point in the history
  • Loading branch information
henrytill committed Nov 10, 2024
1 parent 1b26a78 commit 6cabf60
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages: .

source-repository-package
type: git
location: https://github.com/henrytill/dwergaz
tag: a07426a6e679721730bab68f9d8ce93edc270992
2 changes: 1 addition & 1 deletion lens-toml-parser.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test-suite tests
main-is: Main.hs
build-depends: base >=4.14 && <5
, containers >=0.5 && <0.8
, dwergaz >=0.2 && <0.3
, dwergaz >=0.2
, lens-family >=2.1 && <2.2
, text >=0.2 && <3
, toml-parser >=2.0 && <2.1
Expand Down
35 changes: 13 additions & 22 deletions test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ mapAt k = valueAt k . _Table

testTableKey :: Table -> Test
testTableKey kv =
Expect
assertEqual
"'key' from 'table' == Just \"value\""
(==)
expected
actual
where
Expand All @@ -53,9 +52,8 @@ testTableKey kv =

testTableZoo :: Table -> Test
testTableZoo kv =
Expect
assertEqual
"'zoo' from 'table' == Nothing"
(==)
expected
actual
where
Expand All @@ -64,9 +62,8 @@ testTableZoo kv =

testTableSubtableKey :: Table -> Test
testTableSubtableKey kv =
Expect
assertEqual
"'key' from 'subtable' from 'table' == Just \"another value\""
(==)
expected
actual
where
Expand All @@ -75,9 +72,8 @@ testTableSubtableKey kv =

testTableInlineNameFirst :: Table -> Test
testTableInlineNameFirst kv =
Expect
assertEqual
"'first' from 'name' from 'inline' from 'table' == \"Tom\""
(==)
expected
actual
where
Expand All @@ -86,9 +82,8 @@ testTableInlineNameFirst kv =

testTableInlinePointY :: Table -> Test
testTableInlinePointY kv =
Expect
assertEqual
"'y' from 'point' from 'inline' from 'table' == Just 2"
(==)
expected
actual
where
Expand All @@ -97,9 +92,8 @@ testTableInlinePointY kv =

testStringBasicBasic :: Table -> Test
testStringBasicBasic kv =
Expect
assertEqual
"'basic' from 'basic' from 'string' == <some escaped nonsense>"
(==)
expected
actual
where
Expand All @@ -108,31 +102,28 @@ testStringBasicBasic kv =

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
actual3 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key3" . _Text

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
actual3 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key3" . _Text

testArrayKey1 :: Table -> Test
testArrayKey1 kv =
Expect
assertEqual
"'key1' from 'array' == [1, 2, 3]"
(==)
expected
actual
where
Expand Down Expand Up @@ -164,5 +155,5 @@ main :: IO ()
main = do
ex <- readTomlFile "./example/example-v0.4.0.toml"
let rs = runTests ex
mapM_ print rs
unless (all isPassed rs) exitFailure
mapM_ (putStrLn . resultToString) rs
unless (all resultIsPassed rs) exitFailure

0 comments on commit 6cabf60

Please sign in to comment.