Merge branch 'devel' into araq-big-refactoring
This commit is contained in:
commit
afdd77363e
8 changed files with 36 additions and 12 deletions
|
|
@ -76,6 +76,8 @@
|
||||||
- The `terminal` module now exports additional procs for generating ANSI color
|
- The `terminal` module now exports additional procs for generating ANSI color
|
||||||
codes as strings.
|
codes as strings.
|
||||||
- Added the parameter ``val`` for the ``CritBitTree[int].inc`` proc.
|
- Added the parameter ``val`` for the ``CritBitTree[int].inc`` proc.
|
||||||
|
- An exception raised from ``test`` block of ``unittest`` now show its type in
|
||||||
|
error message
|
||||||
|
|
||||||
### Language additions
|
### Language additions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ Conventions for multi-line statements and expressions
|
||||||
LongTupleA = tuple[wordyTupleMemberOne: int, wordyTupleMemberTwo: string,
|
LongTupleA = tuple[wordyTupleMemberOne: int, wordyTupleMemberTwo: string,
|
||||||
wordyTupleMemberThree: float]
|
wordyTupleMemberThree: float]
|
||||||
|
|
||||||
- Similarly, any procedure and procedure type declarations that are longer#
|
- Similarly, any procedure and procedure type declarations that are longer
|
||||||
than one line should do the same thing.
|
than one line should do the same thing.
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
|
|
@ -198,4 +198,4 @@ Conventions for multi-line statements and expressions
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
startProcess(nimExecutable, currentDirectory, compilerArguments
|
startProcess(nimExecutable, currentDirectory, compilerArguments
|
||||||
environment, processOptions)
|
environment, processOptions)
|
||||||
|
|
|
||||||
|
|
@ -803,6 +803,7 @@ proc acceptAddr*(server: Socket, client: var Socket, address: var string,
|
||||||
else:
|
else:
|
||||||
address = ret[1]
|
address = ret[1]
|
||||||
client.fd = sock
|
client.fd = sock
|
||||||
|
client.domain = getSockDomain(sock)
|
||||||
client.isBuffered = server.isBuffered
|
client.isBuffered = server.isBuffered
|
||||||
|
|
||||||
# Handle SSL.
|
# Handle SSL.
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ when defined(windows):
|
||||||
|
|
||||||
proc existsFile*(filename: string): bool {.rtl, extern: "nos$1",
|
proc existsFile*(filename: string): bool {.rtl, extern: "nos$1",
|
||||||
tags: [ReadDirEffect].} =
|
tags: [ReadDirEffect].} =
|
||||||
## Returns true if the file exists, false otherwise.
|
## Returns true if `filename` exists and is a regular file or symlink.
|
||||||
|
## (directories, device files, named pipes and sockets return false)
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
when useWinUnicode:
|
when useWinUnicode:
|
||||||
wrapUnary(a, getFileAttributesW, filename)
|
wrapUnary(a, getFileAttributesW, filename)
|
||||||
|
|
|
||||||
|
|
@ -462,6 +462,8 @@ template suite*(name, body) {.dirty.} =
|
||||||
finally:
|
finally:
|
||||||
suiteEnded()
|
suiteEnded()
|
||||||
|
|
||||||
|
template exceptionTypeName(e: typed): string = $e.name
|
||||||
|
|
||||||
template test*(name, body) {.dirty.} =
|
template test*(name, body) {.dirty.} =
|
||||||
## Define a single test case identified by `name`.
|
## Define a single test case identified by `name`.
|
||||||
##
|
##
|
||||||
|
|
@ -476,7 +478,7 @@ template test*(name, body) {.dirty.} =
|
||||||
## .. code-block::
|
## .. code-block::
|
||||||
##
|
##
|
||||||
## [OK] roses are red
|
## [OK] roses are red
|
||||||
bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded
|
bind shouldRun, checkpoints, formatters, ensureInitialized, testEnded, exceptionTypeName
|
||||||
|
|
||||||
ensureInitialized()
|
ensureInitialized()
|
||||||
|
|
||||||
|
|
@ -495,8 +497,10 @@ template test*(name, body) {.dirty.} =
|
||||||
|
|
||||||
except:
|
except:
|
||||||
when not defined(js):
|
when not defined(js):
|
||||||
checkpoint("Unhandled exception: " & getCurrentExceptionMsg())
|
let e = getCurrentException()
|
||||||
var stackTrace {.inject.} = getCurrentException().getStackTrace()
|
let eTypeDesc = "[" & exceptionTypeName(e) & "]"
|
||||||
|
checkpoint("Unhandled exception: " & getCurrentExceptionMsg() & " " & eTypeDesc)
|
||||||
|
var stackTrace {.inject.} = e.getStackTrace()
|
||||||
fail()
|
fail()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ proc allocFast(r: var MemRegion; size: int): pointer =
|
||||||
return pointer(it)
|
return pointer(it)
|
||||||
prev = it
|
prev = it
|
||||||
it = it.next
|
it = it.next
|
||||||
|
let size = roundup(size, MemAlign)
|
||||||
if size > r.remaining:
|
if size > r.remaining:
|
||||||
allocSlowPath(r, size)
|
allocSlowPath(r, size)
|
||||||
sysAssert(size <= r.remaining, "size <= r.remaining")
|
sysAssert(size <= r.remaining, "size <= r.remaining")
|
||||||
|
|
@ -288,11 +289,13 @@ proc rawNewSeq(r: var MemRegion, typ: PNimType, size: int): pointer =
|
||||||
result = res +! sizeof(SeqHeader)
|
result = res +! sizeof(SeqHeader)
|
||||||
|
|
||||||
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObj(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
|
sysAssert typ.kind notin {tySequence, tyString}, "newObj cannot be used to construct seqs"
|
||||||
result = rawNewObj(tlRegion, typ, size)
|
result = rawNewObj(tlRegion, typ, size)
|
||||||
zeroMem(result, size)
|
zeroMem(result, size)
|
||||||
when defined(memProfiler): nimProfile(size)
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
proc newObjNoInit(typ: PNimType, size: int): pointer {.compilerRtl.} =
|
||||||
|
sysAssert typ.kind notin {tySequence, tyString}, "newObj cannot be used to construct seqs"
|
||||||
result = rawNewObj(tlRegion, typ, size)
|
result = rawNewObj(tlRegion, typ, size)
|
||||||
when defined(memProfiler): nimProfile(size)
|
when defined(memProfiler): nimProfile(size)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -561,13 +561,16 @@ else:
|
||||||
|
|
||||||
when not declared(nimNewSeqOfCap):
|
when not declared(nimNewSeqOfCap):
|
||||||
proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
|
proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
|
||||||
let s = addInt(mulInt(cap, typ.base.size), GenericSeqSize)
|
when defined(gcRegions):
|
||||||
when declared(newObjNoInit):
|
result = newStr(typ, cap, ntfNoRefs notin typ.base.flags)
|
||||||
result = if ntfNoRefs in typ.base.flags: newObjNoInit(typ, s) else: newObj(typ, s)
|
|
||||||
else:
|
else:
|
||||||
result = newObj(typ, s)
|
let s = addInt(mulInt(cap, typ.base.size), GenericSeqSize)
|
||||||
cast[PGenericSeq](result).len = 0
|
when declared(newObjNoInit):
|
||||||
cast[PGenericSeq](result).reserved = cap
|
result = if ntfNoRefs in typ.base.flags: newObjNoInit(typ, s) else: newObj(typ, s)
|
||||||
|
else:
|
||||||
|
result = newObj(typ, s)
|
||||||
|
cast[PGenericSeq](result).len = 0
|
||||||
|
cast[PGenericSeq](result).reserved = cap
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
|
|
|
||||||
10
tests/stdlib/tunittestexceptiontype.nim
Normal file
10
tests/stdlib/tunittestexceptiontype.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
discard """
|
||||||
|
exitcode: 1
|
||||||
|
outputsub: '''exception type is [ValueError]'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
suite "exception from test":
|
||||||
|
test "show exception type":
|
||||||
|
raise newException(ValueError, "exception type is")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue