summary refs log blame commit diff stats
path: root/tests/stdlib/trepr.nim
blob: 41c830621b7c2c8ac1c3aae0575bd08e8b013aa2 (plain) (tree)
pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp {
discard """
  file: "trepr.nim"
  output: "{a, b}{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}"
"""

type
  TEnum = enum
    a, b
    
var val = {a, b}
stdout.write(repr(val))
stdout.writeln(repr({'a'..'z', 'A'..'Z'}))

type
  TObj {.pure, inheritable.} = object
    data: int
  TFoo = ref object of TObj
    d2: float
var foo: TFoo
new(foo)

when false:
  # cannot capture this output as it contains a memory address :-/
  echo foo.repr
#var testseq: seq[string] = @[
#  "a", "b", "c", "d", "e"
#]
#echo(repr(testseq))
execute line echo "" flushFile(stdout) of "tcp", "": when useCaas: var server = newSocket() let p = getConfigVar(config, "server.port") let port = if p.len > 0: parseInt(p).Port else: 6000.Port server.bindAddr(port, getConfigVar(config, "server.address")) var inp = "".TaintedString server.listen() var stdoutSocket = newSocket() config.writelnHook = proc (line: string) = stdoutSocket.send(line & "\c\L") while true: accept(server, stdoutSocket) stdoutSocket.readLine(inp) execute inp.string stdoutSocket.send("\c\L") stdoutSocket.close() else: msgQuit "server.type not supported; compiler built without caas support" else: echo "Invalid server.type:", typ msgQuit 1