Change expr/stmt in examples to untyped (#6734)

This commit is contained in:
Lynn C. Rees 2017-11-15 13:58:11 -07:00 • committed by Andreas Rumpf
commit ac5dff2e04
16 changed files with 56 additions and 119 deletions

View file

@ -2,8 +2,7 @@
import backend, db_sqlite, strutils, times
proc showPagedResults(conn: DbConn; params: TPagedParams) =
proc showPagedResults(conn: DbConn; params: PagedParams) =
## Shows the contents of the database in pages of specified size.
##
## Hmm... I guess this is more of a debug proc which should be moved outside,
@ -11,7 +10,6 @@ proc showPagedResults(conn: DbConn; params: TPagedParams) =
var
page = 0'i64
rows = conn.getPagedTodos(params)
while rows.len > 0:
echo("page " & $page)
for row in rows:
@ -25,7 +23,6 @@ proc showPagedResults(conn: DbConn; params: TPagedParams) =
else:
break
proc dumTest() =
let conn = openDatabase("todo.sqlite3")
try:
@ -35,10 +32,8 @@ proc dumTest() =
# Fill some dummy rows if there are not many entries yet.
discard conn.addTodo(3, "Filler1")
discard conn.addTodo(4, "Filler2")
var todo = conn.addTodo(2, "Testing")
echo("New todo added with id " & $todo.getId)
# Try changing it and updating the database.
var clonedTodo = conn.getTodo(todo.getId)[]
assert(clonedTodo.text == todo.text, "Should be equal")
@ -49,13 +44,11 @@ proc dumTest() =
echo("Updated priority $1, done $2" % [$todo.priority, $todo.isDone])
else:
assert(false, "Uh oh, I wasn't expecting that!")
# Verify our cloned copy is different but can be updated.
assert(clonedTodo.text != todo.text, "Should be different")
discard clonedTodo.update(conn)
assert(clonedTodo.text == todo.text, "Should be equal")
var params: TPagedParams
var params: PagedParams
params.initDefaults
conn.showPagedResults(params)
conn.deleteTodo(todo.getId)
@ -66,7 +59,6 @@ proc dumTest() =
echo("Later priority $1, done $2" % [$todo.priority, $todo.isDone])
else:
echo("Can't update object $1 from db!" % $todo.getId)
# Try to list content in a different way.
params.pageSize = 5
params.priorityAscending = true
@ -77,7 +69,6 @@ proc dumTest() =
conn.close
echo("Database closed")
# Code that will be run only on the commandline.
when isMainModule:
dumTest()