make tests green again

This commit is contained in:
Andreas Rumpf 2018-07-05 15:51:04 +02:00
commit 0926754e68
31 changed files with 61 additions and 55 deletions

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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) =