make tests green again
This commit is contained in:
parent
9b31f67859
commit
0926754e68
31 changed files with 61 additions and 55 deletions
|
|
@ -1060,6 +1060,8 @@ proc transformExpr*(g: ModuleGraph; module: PSym, n: PNode): PNode =
|
|||
var c = openTransf(g, module, "")
|
||||
result = processTransf(c, n, module)
|
||||
liftDefer(c, result)
|
||||
# expressions are not to be injected with destructor calls as that
|
||||
# the list of top level statements needs to be collected before.
|
||||
if c.needsDestroyPass:
|
||||
result = injectDestructorCalls(g, module, result)
|
||||
incl(result.flags, nfTransf)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ proc foo: bool =
|
|||
return true
|
||||
|
||||
proc err =
|
||||
raise newException(EArithmetic, "some exception")
|
||||
raise newException(ArithmeticError, "some exception")
|
||||
|
||||
test "final test":
|
||||
echo "inside suite-less test"
|
||||
|
|
@ -39,9 +39,9 @@ test "final test":
|
|||
d > 10
|
||||
|
||||
test "arithmetic failure":
|
||||
expect(EArithmetic):
|
||||
expect(ArithmeticError):
|
||||
err()
|
||||
|
||||
expect(EArithmetic, ESystem):
|
||||
expect(ArithmeticError, SystemError):
|
||||
discard foo()
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ proc callC() = callA()
|
|||
|
||||
try:
|
||||
callC()
|
||||
except EAssertionFailed:
|
||||
except AssertionError:
|
||||
write(stdout, "assertion failure!")
|
||||
except:
|
||||
write(stdout, "unknown exception!")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ assignment test a:test b:1 c:2 haha:3
|
|||
# bug #1005
|
||||
|
||||
type
|
||||
TSomeObj = object of TObject
|
||||
TSomeObj = object of RootObj
|
||||
a, b: int
|
||||
PSomeObj = ref object
|
||||
a, b: int
|
||||
|
|
@ -20,7 +20,7 @@ echo a.a, " ", b.a, " ", a.b, " ", b.b
|
|||
# bug #575
|
||||
|
||||
type
|
||||
Something = object of Tobject
|
||||
Something = object of RootObj
|
||||
a: string
|
||||
b, c: int32
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ proc processClient(fd: int) {.async.} =
|
|||
var line = await recvLine(fd)
|
||||
var foo = line[0]
|
||||
if foo == 'g':
|
||||
raise newException(EBase, "foobar")
|
||||
raise newException(Exception, "foobar")
|
||||
|
||||
proc serve() {.async.} =
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import asyncdispatch, strutils
|
|||
|
||||
proc foobar() {.async.} =
|
||||
if 5 == 5:
|
||||
raise newException(EInvalidIndex, "Test")
|
||||
raise newException(IndexError, "Test")
|
||||
|
||||
proc catch() {.async.} =
|
||||
# TODO: Create a test for when exceptions are not caught.
|
||||
|
|
@ -26,26 +26,26 @@ proc catch() {.async.} =
|
|||
|
||||
try:
|
||||
await foobar()
|
||||
except EInvalidIndex:
|
||||
except IndexError:
|
||||
echo("Specific except")
|
||||
|
||||
try:
|
||||
await foobar()
|
||||
except OSError, EInvalidField, EInvalidIndex:
|
||||
except OSError, FieldError, IndexError:
|
||||
echo("Multiple idents in except")
|
||||
|
||||
try:
|
||||
await foobar()
|
||||
except OSError, EInvalidField:
|
||||
except OSError, FieldError:
|
||||
assert false
|
||||
except EInvalidIndex:
|
||||
except IndexError:
|
||||
echo("Multiple except branches")
|
||||
|
||||
try:
|
||||
await foobar()
|
||||
except EInvalidIndex:
|
||||
except IndexError:
|
||||
echo("Multiple except branches 2")
|
||||
except OSError, EInvalidField:
|
||||
except OSError, FieldError:
|
||||
assert false
|
||||
|
||||
waitFor catch()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ when defined(windows):
|
|||
var clientCount = 0
|
||||
|
||||
proc winConnect*(socket: AsyncFD, address: string, port: Port,
|
||||
domain = Domain.AF_INET): Future[void] =
|
||||
domain = Domain.AF_INET): Future[void] =
|
||||
var retFuture = newFuture[void]("winConnect")
|
||||
proc cb(fd: AsyncFD): bool =
|
||||
var ret = SocketHandle(fd).getSockOptInt(cint(SOL_SOCKET), cint(SO_ERROR))
|
||||
|
|
@ -183,7 +183,7 @@ when defined(windows):
|
|||
## **Note**: This procedure is mostly used for testing. You likely want to
|
||||
## use ``asyncnet.recvLine`` instead.
|
||||
|
||||
template addNLIfEmpty(): stmt =
|
||||
template addNLIfEmpty() =
|
||||
if result.len == 0:
|
||||
result.add("\c\L")
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ q[float](0.8, 0.2)
|
|||
|
||||
# bug #942
|
||||
|
||||
template maybeMod(x: Tinteger, module:Natural): untyped =
|
||||
template maybeMod(x: SomeInteger, module: Natural): untyped =
|
||||
if module > 0: x mod module
|
||||
else: x
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ type
|
|||
|
||||
EIO2 = ref object of EIO
|
||||
|
||||
proc raiser(): int {.tags: [TObj, FWriteIO].} =
|
||||
proc raiser(): int {.tags: [TObj, WriteIoEffect].} =
|
||||
writeLine stdout, "arg"
|
||||
|
||||
var o: TObjB
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ type
|
|||
TObj = object {.pure, inheritable.}
|
||||
TObjB = object of TObj
|
||||
a, b, c: string
|
||||
fn: proc (): int {.tags: [FReadIO].}
|
||||
fn: proc (): int {.tags: [ReadIOEffect].}
|
||||
|
||||
EIO2 = ref object of EIO
|
||||
|
||||
proc q() {.tags: [FIO].} =
|
||||
proc q() {.tags: [IoEffect].} =
|
||||
discard
|
||||
|
||||
proc raiser(): int =
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ createMenuItem(s, "Go to definition...",
|
|||
proc (i: PMenuItem, p: pointer) {.cdecl.} =
|
||||
try:
|
||||
echo(i.repr)
|
||||
except EInvalidValue:
|
||||
except ValueError:
|
||||
echo("blah")
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
discard """
|
||||
errormsg: "invalid type: 'expr' in this context: 'proc (a: varargs[expr])' for proc"
|
||||
errormsg: "invalid type: 'untyped' in this context: 'proc (a: varargs[untyped])' for proc"
|
||||
line: 8
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
proc foo(a:varargs[expr]) =
|
||||
proc foo(a:varargs[untyped]) =
|
||||
echo a[0].type.name
|
||||
|
||||
foo(1)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ discard """
|
|||
exitcode: "1"
|
||||
"""
|
||||
type
|
||||
ESomething = object of E_Base
|
||||
ESomeOtherErr = object of E_Base
|
||||
ESomething = object of Exception
|
||||
ESomeOtherErr = object of Exception
|
||||
|
||||
proc genErrors(s: string) =
|
||||
if s == "error!":
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ proc indexOf*(t: typedesc, name: string): int =
|
|||
for n, x in fieldPairs(d):
|
||||
if n == name: return i
|
||||
i.inc
|
||||
raise newException(EInvalidValue, "No field " & name & " in type " &
|
||||
raise newException(ValueError, "No field " & name & " in type " &
|
||||
astToStr(t))
|
||||
|
||||
echo TMyTuple.indexOf("b")
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ when defined(GC_setMaxPause):
|
|||
GC_setMaxPause 2_000
|
||||
|
||||
type
|
||||
TTestObj = object of TObject
|
||||
TTestObj = object of RootObj
|
||||
x: string
|
||||
s: seq[int]
|
||||
|
||||
proc MakeObj(): TTestObj =
|
||||
proc makeObj(): TTestObj =
|
||||
result.x = "Hello"
|
||||
result.s = @[1,2,3]
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ proc inProc() =
|
|||
when defined(gcMarkAndSweep) or defined(boehmgc):
|
||||
GC_fullcollect()
|
||||
var obj: TTestObj
|
||||
obj = MakeObj()
|
||||
obj = makeObj()
|
||||
if getOccupiedMem() > 300_000: quit("still a leak!")
|
||||
|
||||
inProc()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
type
|
||||
Matrix*[M, N: static[int], T: SomeReal] = object
|
||||
Matrix*[M, N: static[int], T: SomeFloat] = object
|
||||
data: ref array[N * M, T]
|
||||
|
||||
Matrix64*[M, N: static[int]] = Matrix[M, N, float64]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
## Created by Eric Doughty-Papassideris on 2011-02-16.
|
||||
|
||||
type
|
||||
TGen[T] = object of TObject
|
||||
TGen[T] = object of RootObj
|
||||
x, y: T
|
||||
|
||||
TSpef[T] = object of TGen[T]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
type
|
||||
TProperty[T] = object of TObject
|
||||
TProperty[T] = object of RootObj
|
||||
getProc: proc(property: TProperty[T]): T {.nimcall.}
|
||||
setProc: proc(property: TProperty[T], value: T) {.nimcall.}
|
||||
value: T
|
||||
|
||||
proc newProperty[T](value: TObject): TProperty[T] =
|
||||
proc newProperty[T](value: RootObj): TProperty[T] =
|
||||
result.getProc = proc (property: TProperty[T]) =
|
||||
return property.value
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ discard """
|
|||
"""
|
||||
|
||||
type
|
||||
Matrix[M,N: static[int]; T: SomeReal] = distinct array[0..(M*N - 1), T]
|
||||
Matrix[M,N: static[int]; T: SomeFloat] = distinct array[0..(M*N - 1), T]
|
||||
|
||||
let a = new Matrix[2,2,float]
|
||||
let b = new Matrix[2,1,float]
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ proc p =
|
|||
|
||||
try:
|
||||
z = parseInt("1233")
|
||||
except E_Base:
|
||||
except Exception:
|
||||
case x
|
||||
of 34: z = 123
|
||||
of 13: z = 34
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
type
|
||||
TIdObj* = object of TObject
|
||||
TIdObj* = object of RootObj
|
||||
id*: int # unique id; use this for comparisons and not the pointers
|
||||
|
||||
PIdObj* = ref TIdObj
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
template filterIt2*(seq, pred: expr, body: stmt): stmt {.immediate, dirty.} =
|
||||
template filterIt2*(seq, pred: untyped, body: untyped) =
|
||||
## sequtils defines a filterIt() that returns a new seq, but this one is called
|
||||
## with a statement body to iterate directly over it
|
||||
for it in items(seq):
|
||||
|
|
@ -13,8 +13,8 @@ proc mapInPlace*[A](x: var seq[A], fun: proc(y: A): A {.closure.}) =
|
|||
for i in 0..x.len-1:
|
||||
x[i] = fun(x[i])
|
||||
|
||||
template unless*(condition: expr; body: stmt): stmt {.dirty.} =
|
||||
if not(condition):
|
||||
template unless*(condition: untyped; body: untyped) {.dirty.} =
|
||||
if not condition:
|
||||
body
|
||||
|
||||
when isMainModule:
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ from strutils import countlines
|
|||
|
||||
type
|
||||
PGuiContainer* = ref TGuiContainer
|
||||
TGuiContainer* = object of TObject
|
||||
TGuiContainer* = object of RootObj
|
||||
position: TVector2f
|
||||
activeEntry: PTextEntry
|
||||
widgets: seq[PGuiObject]
|
||||
buttons: seq[PButton]
|
||||
PGuiObject* = ref TGuiObject
|
||||
TGuiObject* = object of TObject
|
||||
TGuiObject* = object of RootObj
|
||||
PButton* = ref TButton
|
||||
TButton* = object of TGuiObject
|
||||
enabled: bool
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ proc runTask*(name: string) {.inline.}
|
|||
proc shell*(cmd: varargs[string, `$`]): int {.discardable.}
|
||||
proc cd*(dir: string) {.inline.}
|
||||
|
||||
template nakeImports*(): stmt {.immediate.} =
|
||||
template nakeImports*() =
|
||||
import tables, parseopt, strutils, os
|
||||
|
||||
template task*(name: string; description: string; body: stmt): stmt {.dirty, immediate.} =
|
||||
template task*(name: string; description: string; body: untyped) {.dirty.} =
|
||||
block:
|
||||
var t = newTask(description, proc() {.closure.} =
|
||||
body)
|
||||
|
|
@ -40,7 +40,7 @@ proc runTask*(name: string) = tasks[name].action()
|
|||
proc shell*(cmd: varargs[string, `$`]): int =
|
||||
result = execShellCmd(cmd.join(" "))
|
||||
proc cd*(dir: string) = setCurrentDir(dir)
|
||||
template withDir*(dir: string; body: stmt): stmt =
|
||||
template withDir*(dir: string; body: untyped) =
|
||||
## temporary cd
|
||||
## withDir "foo":
|
||||
## # inside foo
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
proc printf(frmt: cstring) {.varargs, importc, header: "<stdio.h>", cdecl.}
|
||||
proc exit(code: int) {.importc, header: "<stdlib.h>", cdecl.}
|
||||
|
||||
proc nimToCStringConv(s: NimString): cstring {.compilerProc, inline.} =
|
||||
if s == nil or s.len == 0: result = cstring""
|
||||
else: result = cstring(addr s.data)
|
||||
|
||||
{.push stack_trace: off, profiler:off.}
|
||||
|
||||
proc rawoutput(s: string) =
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ discard """
|
|||
output: "hello"
|
||||
"""
|
||||
type
|
||||
Test = object of TObject
|
||||
Test = object of RootObj
|
||||
|
||||
method doMethod(a: ref TObject) {.base, raises: [EIO].} =
|
||||
method doMethod(a: ref RootObj) {.base, raises: [IoError].} =
|
||||
quit "override"
|
||||
|
||||
method doMethod(a: ref Test) =
|
||||
echo "hello"
|
||||
if a == nil:
|
||||
raise newException(EIO, "arg")
|
||||
raise newException(IoError, "arg")
|
||||
|
||||
proc doProc(a: ref Test) =
|
||||
echo "hello"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ true
|
|||
|
||||
# bug #1053
|
||||
type
|
||||
TA = object of TObject
|
||||
TA = object of RootObj
|
||||
a: int
|
||||
|
||||
TB = object of TA
|
||||
|
|
@ -32,13 +32,13 @@ test(v)
|
|||
|
||||
# bug #924
|
||||
type
|
||||
MyObject = object of TObject
|
||||
MyObject = object of RootObj
|
||||
x: int
|
||||
|
||||
var
|
||||
asd: MyObject
|
||||
|
||||
proc isMyObject(obj: TObject) =
|
||||
proc isMyObject(obj: RootObj) =
|
||||
echo obj of MyObject
|
||||
if obj of MyObject:
|
||||
let a = MyObject(obj)
|
||||
|
|
@ -46,7 +46,7 @@ proc isMyObject(obj: TObject) =
|
|||
|
||||
asd.x = 5
|
||||
|
||||
#var asdCopy = TObject(asd)
|
||||
#var asdCopy = RootObj(asd)
|
||||
#echo asdCopy of MyObject
|
||||
|
||||
isMyObject(asd)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Covariance is not type safe:
|
||||
|
||||
type
|
||||
TA = object of TObject
|
||||
TA = object of RootObj
|
||||
a: int
|
||||
TB = object of TA
|
||||
b: array[0..5000_000, int]
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ proc find*[TKey, TData](root: PElement[TKey, TData], key: TKey): TData {.raises:
|
|||
if tmp_element.key == key:
|
||||
return tmp_element.left.data
|
||||
else:
|
||||
raise newException(EInvalidKey, "key does not exist: " & key)
|
||||
raise newException(KeyError, "key does not exist: " & key)
|
||||
|
||||
proc add*[TKey, TData](root: var PElement[TKey, TData], key: TKey, data: TData) : bool =
|
||||
if root.left == nil:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ discard """
|
|||
"""
|
||||
# Test the overloading resolution in connection with a qualifier
|
||||
|
||||
proc write(t: TFile, s: string) =
|
||||
proc write(t: File, s: string) =
|
||||
discard # a nop
|
||||
|
||||
system.write(stdout, "hello")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
template withOpenFile(f: untyped, filename: string, mode: TFileMode,
|
||||
template withOpenFile(f: untyped, filename: string, mode: FileMode,
|
||||
actions: untyped): untyped =
|
||||
block:
|
||||
# test that 'f' is implicitly 'injecting':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue