28 changes: 28 additions & 0 deletions tests/ccgbugs/tcgbug.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ success
M1 M2
ok
'''
matrix: "--mm:refc;--mm:orc"
"""

type
Expand Down Expand Up @@ -133,3 +134,30 @@ proc foo = # bug #23280
doAssert L mod 6 == 0

foo()

block: # bug #9940
{.emit:"""/*TYPESECTION*/
typedef struct { int base; } S;
""".}

type S {.importc: "S", completeStruct.} = object
base: cint
proc init(x:ptr S) =
x.base = 1

type
Foo = object
a: seq[float]
b: seq[float]
c: seq[float]
d: seq[float]
s: S

proc newT(): Foo =
var t: Foo
t.s.addr.init
doAssert t.s.base == 1
t

var t = newT()
doAssert t.s.base == 1
31 changes: 31 additions & 0 deletions tests/destructor/t23748.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
discard """
matrix: "--gc:refc; --gc:arc"
output: '''
hello 42
hello 42
len = 2
'''
"""

# bug #23748

type
O = ref object
s: string
cb: seq[proc()]

proc push1(o: O, i: int) =
let o = o
echo o.s, " ", i
o.cb.add(proc() = echo o.s, " ", i)

proc push2(o: O, i: int) =
let o = o
echo o.s, " ", i
proc p() = echo o.s, " ", i
o.cb.add(p)

let o = O(s: "hello", cb: @[])
o.push1(42)
o.push2(42)
echo "len = ", o.cb.len
5 changes: 5 additions & 0 deletions tests/generics/tuninstantiatedgenericcalls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,8 @@ block: # issue #1771

var a: Foo[range[0..2], float]
doAssert test(a) == 0.0

block: # issue #23730
proc test(M: static[int]): array[1 shl M, int] = discard
doAssert len(test(3)) == 8
doAssert len(test(5)) == 32
2 changes: 1 addition & 1 deletion tests/iter/titervaropenarray.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discard """
output: "123"
targets: "c"
targets: "c cpp"
"""
# Try to break the transformation pass:
iterator iterAndZero(a: var openArray[int]): int =
Expand Down
26 changes: 26 additions & 0 deletions tests/pragmas/tpush.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,29 @@ proc main(): void =
{.push staticBoundChecks: on.}

main()


{.push exportC.}

block:
proc foo11() =
const factor = [1, 2, 3, 4]
doAssert factor[0] == 1
proc foo21() =
const factor = [1, 2, 3, 4]
doAssert factor[0] == 1

foo11()
foo21()

template foo31() =
let factor = [1, 2, 3, 4]
doAssert factor[0] == 1
template foo41() =
let factor = [1, 2, 3, 4]
doAssert factor[0] == 1

foo31()
foo41()

{.pop.}
9 changes: 9 additions & 0 deletions tests/refc/tsinkbug.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ var obj = AnObject(value: 42)
echo "Value is: ", obj.value
mutate(obj)
echo "Value is: ", obj.value

proc p(x: sink string) =
var y = move(x)
doAssert x.len == 0
doAssert y.len == 4

p("1234")
var s = "oooo"
p(s)
12 changes: 6 additions & 6 deletions tests/stdlib/thttpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ proc asyncTest() {.async.} =
doAssert("<title>Example Domain</title>" in body)

resp = await client.request("http://example.com/404")
doAssert(resp.code.is4xx)
doAssert(resp.code == Http404)
doAssert(resp.status == $Http404)
doAssert(resp.code.is4xx or resp.code.is5xx)
doAssert(resp.code == Http404 or resp.code == Http500)
doAssert(resp.status == $Http404 or resp.status == $Http500)

when false: # occasionally does not give success code
resp = await client.request("https://google.com/")
Expand Down Expand Up @@ -115,9 +115,9 @@ proc syncTest() =
doAssert("<title>Example Domain</title>" in resp.body)

resp = client.request("http://example.com/404")
doAssert(resp.code.is4xx)
doAssert(resp.code == Http404)
doAssert(resp.status == $Http404)
doAssert(resp.code.is4xx or resp.code.is5xx)
doAssert(resp.code == Http404 or resp.code == Http500)
doAssert(resp.status == $Http404 or resp.status == $Http500)

when false: # occasionally does not give success code
resp = client.request("https://google.com/")
Expand Down