summary refs log tree commit diff stats
path: root/tests/stdlib/tmarshal.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-11-15 18:12:53 +0100
committerGitHub <noreply@github.com>2020-11-15 18:12:53 +0100
commitfc735e4b08d9401dc2b22a1432d1231fa18b4a4f (patch)
treebdac672212785a1f9253d23f1c4fcc385828d571 /tests/stdlib/tmarshal.nim
parent7eb34d170a489c2a0ed90d921f3f7cc6813f19c1 (diff)
parenta86aa310813d326d88959534c36b5499870dcb95 (diff)
downloadNim-fc735e4b08d9401dc2b22a1432d1231fa18b4a4f.tar.gz
fix #15934 and #15620 (#15938) [backport:1.4]
* make workaround for #15934 and #15620
* add testcase for #9754
Diffstat (limited to 'tests/stdlib/tmarshal.nim')
-rw-r--r--tests/stdlib/tmarshal.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim
index fc5703a03..315036631 100644
--- a/tests/stdlib/tmarshal.nim
+++ b/tests/stdlib/tmarshal.nim
@@ -4,6 +4,9 @@ true
 true
 alpha 100
 omega 200
+Some(null)
+None[JsonNode]
+(numeric: "")
 '''
 joinable: false
 """
@@ -123,3 +126,25 @@ var foo = Foo(a2: "", a4: @[], a6: @[1])
 foo.a6.setLen 0
 doAssert $$foo == """{"a1": "", "a2": "", "a3": [], "a4": [], "a5": [], "a6": []}"""
 testit(foo)
+
+import options, json
+
+# bug #15934
+block:
+  let
+    a1 = some(newJNull())
+    a2 = none(JsonNode)
+  echo ($$a1).to[:Option[JsonNode]]
+  echo ($$a2).to[:Option[JsonNode]]
+
+
+#  bug #15620
+block:
+  let str = """{"numeric": null}"""
+
+  type
+    LegacyEntry = object
+      numeric: string
+
+  let test = to[LegacyEntry](str)
+  echo test