Skip to content

Commit 8249bb4

Browse files
committed
Change tests
1 parent 2ddfb1a commit 8249bb4

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

test/Test/Sum.purs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Effect.Console (log)
2020
import Effect.Exception (error, throw)
2121
import Test.QuickCheck (class Arbitrary, arbitrary, quickCheck)
2222
import Test.QuickCheck.Arbitrary (genericArbitrary)
23-
import Test.QuickCheck.Gen (Gen)
2423
import Test.Util (propCodec)
2524

2625
--------------------------------------------------------------------------------
@@ -51,7 +50,11 @@ codecSample encoding = sumWith encoding "Sample"
5150
data SampleFlat
5251
= FlatFoo
5352
| FlatBar { errors Int }
54-
| FlatBaz { active Boolean, name String, count Int }
53+
| FlatBaz
54+
{ active Boolean
55+
, name String
56+
, pos { x Int, y Int }
57+
}
5558

5659
derive instance Generic SampleFlat _
5760
derive instance Eq SampleFlat
@@ -66,7 +69,14 @@ codecSampleFlat ∷ JsonCodec SampleFlat
6669
codecSampleFlat = sumFlat @"tag" "Sample"
6770
{ "FlatFoo": unit
6871
, "FlatBar": CR.record { errors: C.int }
69-
, "FlatBaz": CR.record { active: C.boolean, name: C.string, count: C.int }
72+
, "FlatBaz": CR.record
73+
{ active: C.boolean
74+
, name: C.string
75+
, pos: CR.object "Pos"
76+
{ x: C.int
77+
, y: C.int
78+
}
79+
}
7080
}
7181

7282
--------------------------------------------------------------------------------
@@ -360,13 +370,16 @@ main = do
360370
, "}"
361371
]
362372

363-
check codecSampleFlat (FlatBaz { active: true, name: "hello", count: 42 })
373+
check codecSampleFlat (FlatBaz { active: true, name: "hello", pos: { x: 42, y: 42 } })
364374
$ Str.joinWith "\n"
365375
[ "{"
366376
, " \"tag\": \"FlatBaz\","
367377
, " \"active\": true,"
368-
, " \"count\": 42,"
369-
, " \"name\": \"hello\""
378+
, " \"name\": \"hello\","
379+
, " \"pos\": {"
380+
, " \"x\": 42,"
381+
, " \"y\": 42"
382+
, " }"
370383
, "}"
371384
]
372385

0 commit comments

Comments
 (0)