close #17986 add testcase (#18477)

This commit is contained in:
flywind 2021-07-13 06:18:07 +08:00 • committed by GitHub
commit 1b128ac045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -311,6 +311,18 @@ template fn() =
doAssert guide == AboutLifeUniverseAndEverythingElse( doAssert guide == AboutLifeUniverseAndEverythingElse(
question: "6*9=?", answer: 42) question: "6*9=?", answer: 42)
block refObject: #bug 17986
type A = ref object
case is_a: bool
of true:
a: int
else:
b: int
var a = A()
fromJson(a, """{"is_a": true, "a":1, "extra_key": 1}""".parse_json, Joptions(allowExtraKeys: true))
doAssert $a[] == "(is_a: true, a: 1)"
block testAllowMissingKeys: block testAllowMissingKeys:
var guide = AboutLifeUniverseAndEverythingElse( var guide = AboutLifeUniverseAndEverythingElse(
question: "6*9=?", answer: 54) question: "6*9=?", answer: 54)