start of tests refactoring; sqlite3 new wrapper fixes
This commit is contained in:
parent
6bc16904ed
commit
d913fdb280
173 changed files with 206 additions and 238 deletions
26
tests/accept/compile/ttempl3.nim
Normal file
26
tests/accept/compile/ttempl3.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue