new tester; all tests categorized

This commit is contained in:
Araq 2014-01-13 02:10:03 +01:00
commit 20b5f31c03
481 changed files with 794 additions and 2506 deletions

23
tests/notnil/tnotnil.nim Normal file
View file

@ -0,0 +1,23 @@
discard """
line: 22
errormsg: "type mismatch"
"""
type
PObj = ref TObj not nil
TObj = object
x: int
MyString = string not nil
#var x: PObj = nil
proc p(x: string not nil): int =
result = 45
proc q(x: MyString) = nil
proc q2(x: string) = nil
q2(nil)
q(nil)

40
tests/notnil/tnotnil1.nim Normal file
View file

@ -0,0 +1,40 @@
discard """
errormsg: "'y' is provably nil"
line:38
"""
import strutils
type
TObj = object
x, y: int
type
superstring = string not nil
proc q(s: superstring) =
echo s
proc p2() =
var a: string = "I am not nil"
q(a) # but this should and does not
p2()
proc q(x: pointer not nil) =
nil
proc p() =
var x: pointer
if not x.isNil:
q(x)
let y = x
if not y.isNil:
q(y)
else:
q(y)
p()

24
tests/notnil/tnotnil2.nim Normal file
View file

@ -0,0 +1,24 @@
discard """
errormsg: "cannot prove 'y' is not nil"
line:20
"""
import strutils
type
TObj = object
x, y: int
proc q(x: pointer not nil) =
nil
proc p() =
var x: pointer
let y = x
if not y.isNil or y != x:
q(y)
else:
q(y)
p()