1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
discard """
matrix: "--mm:refc; --mm:orc"
output: '''@[11, 12, 13]
@[11, 12, 13]
@[1, 3, 5]
@[1, 3, 5]
gppcbs
gppcbs
fpqeew
fpqeew
[11, 12, 13]
[11, 12, 13]
[11, 12, 13]
[11, 12, 13]
11 12 13
[11,12,13]
<Students>
<Student Name="Aprilfoo" />
<Student Name="bar" />
</Students>
<chapter>
<title>This is a Docbook title</title>
<para>
This is a Docbook paragraph containing <emphasis>emphasized</emphasis>,
<literal>literal</literal> and <replaceable>replaceable</replaceable>
text. Sometimes scrunched together like this:
<literal>literal</literal><replaceable>replaceable</replaceable>
and sometimes not:
<literal>literal</literal> <replaceable>replaceable</replaceable>
</para>
</chapter>'''
"""
block:
var xs = @[1,2,3]
for x in xs.mitems:
x += 10
echo xs
block:
var xs = [1,2,3]
for x in xs.mitems:
x += 10
echo(@xs)
block:
var xs = @[1,2,3]
for i, x in xs.mpairs:
x += i
echo xs
block:
var xs = [1,2,3]
for i, x in xs.mpairs:
x += i
echo(@xs)
block:
var x = "foobar"
for c in x.mitems:
inc c
echo x
block:
var x = "foobar"
prepareMutation(x)
var y = cast[cstring](addr x[0])
for c in y.mitems:
inc c
echo x
block:
var x = "foobar"
for i, c in x.mpairs:
inc c, i
echo x
block:
var x = "foobar"
prepareMutation(x)
var y = cast[cstring](addr x[0])
for i, c in y.mpairs:
inc c, i
echo x
import lists
block:
var sl = initSinglyLinkedList[int]()
sl.prepend(3)
sl.prepend(2)
sl.prepend(1)
for x in sl.mitems:
x += 10
echo sl
block:
var sl = initDoublyLinkedList[int]()
sl.append(1)
sl.append(2)
sl.append(3)
for x in sl.mitems:
x += 10
echo sl
block:
var sl = initDoublyLinkedRing[int]()
sl.append(1)
sl.append(2)
sl.append(3)
for x in sl.mitems:
x += 10
echo sl
import deques
block:
var q = initDeque[int]()
q.addLast(1)
q.addLast(2)
q.addLast(3)
for x in q.mitems:
x += 10
echo q
import json
block:
var j = parseJson """{"key1": 1, "key2": 2, "key3": 3}"""
for key,val in j.pairs:
val.num += 10
echo j["key1"], " ", j["key2"], " ", j["key3"]
block:
var j = parseJson """[1, 2, 3]"""
for x in j.mitems:
x.num += 10
echo j
import xmltree, xmlparser, parsexml, streams, strtabs
block:
var d = parseXml(newStringStream """<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
</Students>""")
for x in d.mitems:
x = <>Student(Name=x.attrs["Name"] & "foo")
d[1].attrs["Name"] = "bar"
echo d
block:
var d = parseXml(newStringStream """<chapter>
<title>This is a Docbook title</title>
<para>
This is a Docbook paragraph containing <emphasis>emphasized</emphasis>,
<literal>literal</literal> and <replaceable>replaceable</replaceable>
text. Sometimes scrunched together like this:
<literal>literal</literal><replaceable>replaceable</replaceable>
and sometimes not:
<literal>literal</literal> <replaceable>replaceable</replaceable>
</para>
</chapter>""",{reportComments, reportWhitespace})
echo d
|