got rid of 'accept' dir in the tests

This commit is contained in:
Araq 2011-11-19 15:45:51 +01:00
commit a274f3bf5b
264 changed files with 5 additions and 7 deletions

42
tests/compile/ttempl3.nim Executable file
View file

@ -0,0 +1,42 @@
template withOpenFile(f: expr, filename: string, mode: TFileMode,
actions: stmt): stmt =
block:
var f: TFile
if open(f, filename, mode):
try:
actions
finally:
close(f)
else:
quit("cannot open for writing: " & filename)
withOpenFile(txt, "ttempl3.txt", fmWrite):
writeln(txt, "line 1")
txt.writeln("line 2")
# Test zero argument template:
template ha: expr = myVar[0]
var
myVar: array[0..1, int]
ha = 1
echo(ha)
# Test identifier generation:
template prefix(name: expr): expr = `"hu" name`
var `hu "XYZ"` = "yay"
echo prefix(XYZ)
template typedef(name: expr, typ: typeDesc) =
type
`T name`* = typ
`P name`* = ref `T name`
typedef(myint, int)
var x: PMyInt