diff options
author | inv2004 <inv2004@gmail.com> | 2021-01-06 20:42:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-06 18:42:49 +0100 |
commit | 0d5cab77f65df1431ed417a666ba49136af3b2c1 (patch) | |
tree | 3be7eee23052b510b38ba8ecfc0088b7305e529b /tests/stdlib | |
parent | 58b9191354aa99ac2d17f9a7db3bdf239c7bce6b (diff) | |
download | Nim-0d5cab77f65df1431ed417a666ba49136af3b2c1.tar.gz |
jsonutils: fromJson forward opt param fix (#16612)
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/tjsonutils.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/stdlib/tjsonutils.nim b/tests/stdlib/tjsonutils.nim index 28f05ecbe..f56c32719 100644 --- a/tests/stdlib/tjsonutils.nim +++ b/tests/stdlib/tjsonutils.nim @@ -118,6 +118,20 @@ template fn() = testRoundtrip(Foo[int](t1: false, z2: 7)): """{"t1":false,"z2":7}""" # pending https://github.com/nim-lang/Nim/issues/14698, test with `type Foo[T] = ref object` + block: # bug: pass opt params in fromJson + type Foo = object + a: int + b: string + c: float + var f: seq[Foo] + try: + fromJson(f, parseJson """[{"b": "bbb"}]""") + doAssert false + except ValueError: + doAssert true + fromJson(f, parseJson """[{"b": "bbb"}]""", Joptions(allowExtraKeys: true, allowMissingKeys: true)) + doAssert f == @[Foo(a: 0, b: "bbb", c: 0.0)] + block testHashSet: testRoundtrip(HashSet[string]()): "[]" testRoundtrip([""].toHashSet): """[""]""" |