eliminate warnings with nim-0.17.0 #1

Merged
stefantalpalaru merged 2 commits from warnings into master 2017-06-20 20:58:01 +00:00
3 changed files with 40 additions and 20 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
nimcache/ nimcache/
*.swp *.swp
*.swo *.swo
/tests/test

View file

@ -13,7 +13,8 @@
## self.checkRaises(OSError, newException(OSError, "OS is exploding!")) ## self.checkRaises(OSError, newException(OSError, "OS is exploding!"))
## ##
import macros import macros
import strutils import unicode
import strutils except toLower
import tables import tables
import typetraits import typetraits
when not defined(ECMAScript): when not defined(ECMAScript):
@ -115,15 +116,15 @@ type
# -- Methods for the TestSuite base -- # -- Methods for the TestSuite base --
method setup*(suite: TestSuite) = method setup*(suite: TestSuite) {.base.} =
## Base method for setup code ## Base method for setup code
discard discard
method tearDown*(suite: TestSuite) = method tearDown*(suite: TestSuite) {.base.} =
## Base method for tearDown code ## Base method for tearDown code
discard discard
method runTests*(suite: TestSuite) = method runTests*(suite: TestSuite) {.base.} =
## Base method for running tests ## Base method for running tests
discard discard
@ -153,8 +154,8 @@ template returnException(name, testName, snip, vals, pos, posRel) =
# ------------------------ Templates for checking ---------------------------- # ------------------------ Templates for checking ----------------------------
template checkRaises*(self: TestSuite, error: Exception, template checkRaises*(self: untyped, error: untyped,
code: untyped): untyped {.immediate.}= code: untyped): untyped =
## Raises a TestAssertError when the exception "error" is ## Raises a TestAssertError when the exception "error" is
## not thrown in the code ## not thrown in the code
let let
@ -184,7 +185,7 @@ template checkRaises*(self: TestSuite, error: Exception,
returnException("checkRaises", testName, snip, vals, pos, posRel) returnException("checkRaises", testName, snip, vals, pos, posRel)
template recursive(node, action): expr {.dirty.} = template recursive(node, action): untyped {.dirty.} =
## recursively iterate over AST nodes and perform an ## recursively iterate over AST nodes and perform an
## action on them ## action on them
proc helper(child: NimNode): NimNode {.gensym.} = proc helper(child: NimNode): NimNode {.gensym.} =
@ -244,7 +245,7 @@ macro getSyms(code:untyped): untyped =
initTable[string, string]() initTable[string, string]()
result = getAst(emptyTable()) result = getAst(emptyTable())
template check*(self: TestSuite, code: untyped){.immediate.}= template check*(self: untyped, code: untyped)=
## Assertions for tests ## Assertions for tests
if not code: if not code:
# These need to be here to capture the actual info # These need to be here to capture the actual info
@ -430,7 +431,7 @@ macro testSuite*(head: untyped, body: untyped): untyped =
template runTestsProc(self, typeName, baseMethod, typeMethod) = template runTestsProc(self, typeName, baseMethod, typeMethod) =
method typeMethod(self: typeName) = method typeMethod(self: typeName) {.base.} =
when compiles(self.baseMethod()): when compiles(self.baseMethod()):
self.baseMethod() self.baseMethod()
@ -446,6 +447,20 @@ macro testSuite*(head: untyped, body: untyped): untyped =
foundSetup = false foundSetup = false
foundTeardown = false foundTeardown = false
# {.push warning[UseBase]: off.}
result.add(
newNimNode(nnkPragma).add(
ident("push"),
newNimNode(nnkExprColonExpr).add(
newNimNode(nnkBracketExpr).add(
ident("warning"),
ident("UseBase")
),
ident("off")
)
)
)
# Make forward declarations so that function order # Make forward declarations so that function order
# does not matter, just like in real OOP! # does not matter, just like in real OOP!
for node in body.children: for node in body.children:
@ -473,10 +488,17 @@ macro testSuite*(head: untyped, body: untyped): untyped =
else: else:
discard discard
# {.pop.}
result.add(
newNimNode(nnkPragma).add(
ident("pop")
)
)
if not foundSetup: if not foundSetup:
template setupProc(self, typeName, setupProc) = template setupProc(self, typeName, setupProc) =
method setup(self: typeName) method setup(self: typeName)
method setupProc(self: typeName) method setupProc(self: typeName) {.base.}
template setupDecl(self, baseMethod) = template setupDecl(self, baseMethod) =
method setup() = method setup() =
@ -492,7 +514,7 @@ macro testSuite*(head: untyped, body: untyped): untyped =
if not foundTeardown: if not foundTeardown:
template teardownProc(self, typeName, tdProc) = template teardownProc(self, typeName, tdProc) =
method tearDown(self: typeName) method tearDown(self: typeName)
method tdProc(self: typeName) method tdProc(self: typeName) {.base.}
template teardownDecl(self, baseMethod) = template teardownDecl(self, baseMethod) =
method tearDown() = method tearDown() =

View file

@ -45,10 +45,6 @@ else:
ws_xpixel: cushort ws_xpixel: cushort
jyapayne commented 2017-06-20 20:31:18 +00:00 (Migrated from github.com)

These can just be deleted. I put them in here because I was going to use them but forgot to remove them :)

These can just be deleted. I put them in here because I was going to use them but forgot to remove them :)
ws_ypixel: cushort ws_ypixel: cushort
let
IOC_OUT = 0x40000000
IOCPARM_MASK = 0x1fff
var var
TIOCGWINSZ{.importc: "TIOCGWINSZ", header: "<sys/ioctl.h>".}: uint TIOCGWINSZ{.importc: "TIOCGWINSZ", header: "<sys/ioctl.h>".}: uint