make tests green again

This commit is contained in:
Andreas Rumpf 2019-03-04 22:44:23 +01:00
commit f907354121
7 changed files with 14 additions and 24 deletions

View file

@ -11,7 +11,6 @@ deallocating
allocating allocating
deallocating deallocating
''' '''
cmd: '''nim c --newruntime $file'''
""" """
type type
@ -125,7 +124,7 @@ proc `=`*[T](m: var MySeq[T], m2: MySeq[T]) =
`=destroy`(m) `=destroy`(m)
m.len = m2.len m.len = m2.len
let bytes = m.len.int * sizeof(float) let bytes = m.len.int * sizeof(float)
if bytes > 0: if bytes > 0:
m.data = cast[ptr UncheckedArray[T]](allocShared(bytes)) m.data = cast[ptr UncheckedArray[T]](allocShared(bytes))
copyMem(m.data, m2.data, bytes) copyMem(m.data, m2.data, bytes)

View file

@ -1,7 +1,3 @@
discard """
cmd: '''nim c --newruntime $file'''
"""
# Make sure we don't walk cast[T] type section while injecting sinks/destructors # Make sure we don't walk cast[T] type section while injecting sinks/destructors
block: block:
type type

View file

@ -16,7 +16,6 @@ discard """
1 2 6 1 2 6
1 3 7 1 3 7
after 6 6''' after 6 6'''
cmd: '''nim c --newruntime $file'''
""" """
import typetraits import typetraits

View file

@ -5,7 +5,6 @@ foo bar to appendmore here
foo bar to appendmore here foo bar to appendmore here
foo bar to appendmore here foo bar to appendmore here
after 20 20''' after 20 20'''
cmd: '''nim c --newruntime $file'''
""" """
{.this: self.} {.this: self.}

View file

@ -6,7 +6,6 @@ destroy
123 123
destroy Foo: 5 destroy Foo: 5
destroy Foo: 123''' destroy Foo: 123'''
cmd: '''nim c --newruntime $file'''
""" """
# bug #2821 # bug #2821

View file

@ -7,7 +7,6 @@ test destroyed 0
3 3
4 4
Pony is dying!''' Pony is dying!'''
cmd: '''nim c --newruntime $file'''
""" """
# bug #4214 # bug #4214
@ -68,7 +67,7 @@ for x in getPony():
type type
MySeqNonCopyable* = object MySeqNonCopyable* = object
len: int len: int
data: ptr UncheckedArray[float] data: ptr UncheckedArray[float]
proc `=destroy`*(m: var MySeqNonCopyable) {.inline.} = proc `=destroy`*(m: var MySeqNonCopyable) {.inline.} =
@ -93,7 +92,7 @@ proc `[]`*(m: MySeqNonCopyable; i: int): float {.inline.} =
proc `[]=`*(m: var MySeqNonCopyable; i, val: float) {.inline.} = proc `[]=`*(m: var MySeqNonCopyable; i, val: float) {.inline.} =
m.data[i.int] = val m.data[i.int] = val
proc setTo(s: var MySeqNonCopyable, val: float) = proc setTo(s: var MySeqNonCopyable, val: float) =
for i in 0..<s.len.int: for i in 0..<s.len.int:
s.data[i] = val s.data[i] = val
@ -110,18 +109,18 @@ proc myfunc(x, y: int): (MySeqNonCopyable, MySeqNonCopyable) =
proc myfunc2(x, y: int): tuple[a: MySeqNonCopyable, b:int, c:MySeqNonCopyable] = proc myfunc2(x, y: int): tuple[a: MySeqNonCopyable, b:int, c:MySeqNonCopyable] =
var cc = newMySeq(y, 5.0) var cc = newMySeq(y, 5.0)
(a: case x: (a: case x:
of 1: of 1:
let (z1, z2) = myfunc(x,y) let (z1, z2) = myfunc(x,y)
z2 z2
elif x > 5: raise newException(ValueError, "new error") elif x > 5: raise newException(ValueError, "new error")
else: newMySeq(x, 1.0), else: newMySeq(x, 1.0),
b: 0, b: 0,
c: block: c: block:
var tmp = if y > 0: move(cc) else: newMySeq(1, 3.0) var tmp = if y > 0: move(cc) else: newMySeq(1, 3.0)
tmp[0] = 5 tmp[0] = 5
tmp tmp
) )
let (seq1, seq2) = myfunc(2, 3) let (seq1, seq2) = myfunc(2, 3)
doAssert seq1.len == 2 doAssert seq1.len == 2
@ -141,20 +140,20 @@ seq4 = block:
tmp[0] = 3.0 tmp[0] = 3.0
tmp tmp
doAssert seq4[0] == 3.0 doAssert seq4[0] == 3.0
import macros import macros
seq4 = seq4 =
if i > 0: newMySeq(2, 5.0) if i > 0: newMySeq(2, 5.0)
elif i < -100: raise newException(ValueError, "Parse Error") elif i < -100: raise newException(ValueError, "Parse Error")
else: newMySeq(2, 3.0) else: newMySeq(2, 3.0)
seq4 = seq4 =
case (char) i: case (char) i:
of 'A', {'W'..'Z'}: newMySeq(2, 5.0) of 'A', {'W'..'Z'}: newMySeq(2, 5.0)
of 'B': quit(-1) of 'B': quit(-1)
else: else:
let (x1, x2, x3) = myfunc2(2, 3) let (x1, x2, x3) = myfunc2(2, 3)
x3 x3

View file

@ -8,7 +8,6 @@ discard """
90.0 90.0
120.0 120.0
8 8''' 8 8'''
cmd: '''nim c --newruntime $file'''
""" """
import typetraits import typetraits