Merge branch 'devel' into araq-fixes-7833
This commit is contained in:
commit
9235f7a3b3
28 changed files with 399 additions and 173 deletions
|
|
@ -16,9 +16,12 @@ proc main =
|
|||
dealloc p
|
||||
# c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size)
|
||||
when defined(cpu64):
|
||||
# bug #7120
|
||||
var x = alloc(((1 shl 29) - 4) * 8)
|
||||
dealloc x
|
||||
# see https://github.com/nim-lang/Nim/issues/8509
|
||||
# this often made appveyor (on windows) fail with out of memory
|
||||
when defined(posix):
|
||||
# bug #7120
|
||||
var x = alloc(((1 shl 29) - 4) * 8)
|
||||
dealloc x
|
||||
|
||||
main()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
discard """
|
||||
msg: '''initApple
|
||||
deinitApple
|
||||
Coral
|
||||
enum
|
||||
redCoral, blackCoral'''
|
||||
output: '''TFoo
|
||||
TBar'''
|
||||
"""
|
||||
|
|
@ -23,3 +28,40 @@ macro test: untyped =
|
|||
bindSym("TBar"))
|
||||
|
||||
test()
|
||||
|
||||
# issue 7827, bindSym power up
|
||||
{.experimental: "dynamicBindSym".}
|
||||
type
|
||||
Apple = ref object
|
||||
name: string
|
||||
color: int
|
||||
weight: int
|
||||
|
||||
proc initApple(name: string): Apple =
|
||||
discard
|
||||
|
||||
proc deinitApple(x: Apple) =
|
||||
discard
|
||||
|
||||
macro wrapObject(obj: typed, n: varargs[untyped]): untyped =
|
||||
let m = n[0]
|
||||
for x in m:
|
||||
var z = bindSym x
|
||||
echo z.repr
|
||||
|
||||
wrapObject(Apple):
|
||||
initApple
|
||||
deinitApple
|
||||
|
||||
type
|
||||
Coral = enum
|
||||
redCoral
|
||||
blackCoral
|
||||
|
||||
macro mixer(): untyped =
|
||||
let m = "Co" & "ral"
|
||||
let x = bindSym(m)
|
||||
echo x.repr
|
||||
echo getType(x).repr
|
||||
|
||||
mixer()
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ else:
|
|||
echo getLastModificationTime("a") == tm
|
||||
removeFile("a")
|
||||
|
||||
when defined(Linux) or defined(osx):
|
||||
when defined(posix):
|
||||
|
||||
block normalizedPath:
|
||||
block relative:
|
||||
|
|
|
|||
18
tests/system/t7894.nim
Normal file
18
tests/system/t7894.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
discard """
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
const size = 250000000
|
||||
var saved = newSeq[seq[int8]]()
|
||||
|
||||
for i in 0..22:
|
||||
# one of these is 0.25GB.
|
||||
#echo i
|
||||
var x = newSeq[int8](size)
|
||||
sleep(10)
|
||||
saved.add(x)
|
||||
|
||||
for x in saved:
|
||||
#echo x.len
|
||||
doAssert x.len == size
|
||||
|
|
@ -1,54 +1,57 @@
|
|||
discard """
|
||||
"""
|
||||
|
||||
var x: ptr int
|
||||
|
||||
x = cast[ptr int](alloc(7))
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x = cast[ptr int](x.realloc(2))
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = createU(int, 3)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = create(int, 4)
|
||||
assert cast[ptr array[4, int]](x)[0] == 0
|
||||
assert cast[ptr array[4, int]](x)[1] == 0
|
||||
assert cast[ptr array[4, int]](x)[2] == 0
|
||||
assert cast[ptr array[4, int]](x)[3] == 0
|
||||
doAssert cast[ptr array[4, int]](x)[0] == 0
|
||||
doAssert cast[ptr array[4, int]](x)[1] == 0
|
||||
doAssert cast[ptr array[4, int]](x)[2] == 0
|
||||
doAssert cast[ptr array[4, int]](x)[3] == 0
|
||||
|
||||
x = x.resize(4)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = cast[ptr int](allocShared(100))
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
deallocShared(x)
|
||||
|
||||
x = createSharedU(int, 3)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.deallocShared()
|
||||
|
||||
x = createShared(int, 3)
|
||||
assert x != nil
|
||||
assert cast[ptr array[3, int]](x)[0] == 0
|
||||
assert cast[ptr array[3, int]](x)[1] == 0
|
||||
assert cast[ptr array[3, int]](x)[2] == 0
|
||||
doAssert x != nil
|
||||
doAssert cast[ptr array[3, int]](x)[0] == 0
|
||||
doAssert cast[ptr array[3, int]](x)[1] == 0
|
||||
doAssert cast[ptr array[3, int]](x)[2] == 0
|
||||
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x = cast[ptr int](x.resizeShared(2))
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.deallocShared()
|
||||
|
||||
x = create(int, 10)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x = x.resize(12)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.dealloc()
|
||||
|
||||
x = createShared(int, 1)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x = x.resizeShared(1)
|
||||
assert x != nil
|
||||
doAssert x != nil
|
||||
x.deallocShared()
|
||||
|
||||
x = cast[ptr int](alloc0(125 shl 23))
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
discard """
|
||||
"""
|
||||
|
||||
const
|
||||
nmax = 2*1024*1024*1024
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ proc main() =
|
|||
for val in table.values():
|
||||
if myObj2.isNil:
|
||||
myObj2 = val
|
||||
assert(myObj == myObj2) # passes
|
||||
doAssert(myObj == myObj2) # passes
|
||||
|
||||
var tableCopy: ListTableRef[int, SomeObj]
|
||||
deepCopy(tableCopy, table)
|
||||
|
|
@ -80,7 +80,7 @@ proc main() =
|
|||
#echo cast[int](myObjCopy)
|
||||
#echo cast[int](myObjCopy2)
|
||||
|
||||
assert(myObjCopy == myObjCopy2) # fails
|
||||
doAssert(myObjCopy == myObjCopy2) # fails
|
||||
|
||||
|
||||
type
|
||||
|
|
@ -88,7 +88,7 @@ type
|
|||
counter, max: int
|
||||
data: array[0..99, (pointer, pointer)]
|
||||
|
||||
assert(sizeof(PtrTable) == 2*sizeof(int)+sizeof(pointer)*2*100)
|
||||
doAssert(sizeof(PtrTable) == 2*sizeof(int)+sizeof(pointer)*2*100)
|
||||
|
||||
main()
|
||||
echo "ok"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
discard """
|
||||
"""
|
||||
|
||||
import
|
||||
unittest, osproc, streams, os, strformat
|
||||
const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
|
|
@ -36,7 +39,7 @@ proc verifyFileSize(sz: int64) =
|
|||
discard execProcess(&"dd if=/dev/zero of={fn} bs=1000000 count={size_in_mb}")
|
||||
|
||||
doAssert os.getFileSize(fn) == sz # Verify OS filesize by string
|
||||
|
||||
|
||||
var f = open(fn)
|
||||
doAssert f.getFileSize() == sz # Verify file handle filesize
|
||||
f.close()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
discard """
|
||||
"""
|
||||
|
||||
import os
|
||||
import osproc
|
||||
import parseopt2
|
||||
|
|
@ -7,12 +10,12 @@ let argv = commandLineParams()
|
|||
|
||||
if argv == @[]:
|
||||
# this won't work with spaces
|
||||
assert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0
|
||||
doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0
|
||||
else:
|
||||
let f = toSeq(getopt())
|
||||
echo f.repr
|
||||
assert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
|
||||
assert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
|
||||
assert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d"
|
||||
assert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == ""
|
||||
assert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""
|
||||
doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
|
||||
doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
|
||||
doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d"
|
||||
doAssert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == ""
|
||||
doAssert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""
|
||||
|
|
|
|||
|
|
@ -54,4 +54,9 @@ static:
|
|||
new(s)
|
||||
var ss = s
|
||||
s[] = 1
|
||||
doAssert ss[] == 1
|
||||
doAssert ss[] == 1
|
||||
|
||||
static: # bug #8402
|
||||
type R = ref object
|
||||
var empty: R
|
||||
let otherEmpty = empty
|
||||
Loading…
Add table
Add a link
Reference in a new issue