summary refs log tree commit diff stats
path: root/tests/stdlib/tjsonmacro_reject2.nim
blob: b01153553c59eba6f92168e42ff7f0a258bbbcd1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
discard """
  file: "tjsonmacro_reject2.nim"
  line: 10
  errormsg: "The `to` macro does not support ref objects with cycles."
"""
import json

type
  Misdirection = object
    cycle: Cycle

  Cycle = ref object
    foo: string
    cycle: Misdirection

let data = """
  {"cycle": null}
"""

let dataParsed = parseJson(data)
let dataDeser = to(dataParsed, Cycle)
} /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
discard """
  file: "tcopy.nim"
  output: "TEMP=C:\\Programs\\xyz\\bin"
"""
# tests the substr proc

import
  strutils

proc main() =
  const
    example = r"TEMP=C:\Programs\xyz\bin"
  var
    a, b: string
    p: int
  p = find(example, "=")
  a = substr(example, 0, p-1)
  b = substr(example, p+1)
  writeLine(stdout, a & '=' & b)
  #writeLine(stdout, b)

main()
#OUT TEMP=C:\Programs\xyz\bin