Skip to content

Commit

Permalink
fix #13531 by adding a test (#13581)
Browse files Browse the repository at this point in the history
  • Loading branch information
narimiran authored Mar 4, 2020
1 parent 34c16f5 commit 9961d1f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/stdlib/tjson_unmarshall.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
discard """
output: '''
Original: (kind: P, pChildren: @[(kind: Text, textStr: "mychild"), (kind: Br)])
jsonNode: {"kind":"P","pChildren":[{"kind":"Text","textStr":"mychild"},{"kind":"Br"}]}
Reversed: (kind: P, pChildren: @[(kind: Text, textStr: "mychild"), (kind: Br)])
'''
"""

import json

type
ContentNodeKind* = enum
P,
Br,
Text,
ContentNode* = object
case kind*: ContentNodeKind
of P: pChildren*: seq[ContentNode]
of Br: nil
of Text: textStr*: string

let mynode = ContentNode(kind: P, pChildren: @[
ContentNode(kind: Text, textStr: "mychild"),
ContentNode(kind: Br)
])

echo "Original: " & $mynode

let jsonNode = %*mynode
echo "jsonNode: " & $jsonNode
echo "Reversed: " & $jsonNode.to(ContentNode)

0 comments on commit 9961d1f

Please sign in to comment.