cleanup of the tests

This commit is contained in:
Andreas Rumpf 2017-04-11 16:55:51 +02:00
commit b22567d9e0

View file

@ -3,13 +3,14 @@ import vdom, times, karax, karaxdsl, jdict, jstrutils, parseutils, sequtils
var var
entries: seq[cstring] entries: seq[cstring]
results: seq[cstring]
timeout : Timeout timeout : Timeout
proc reset() = proc reset() =
kout cstring"reset started" results.add cstring"reset started"
entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ] entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ]
redraw() redraw()
kout cstring"reset finished" results.add cstring"reset finished"
proc checkOrder(order : seq[int]): bool = proc checkOrder(order : seq[int]): bool =
var ul = getElementById("ul") var ul = getElementById("ul")
@ -25,13 +26,13 @@ proc checkOrder(order : seq[int]): bool =
proc check1() = proc check1() =
let result = checkOrder(@[0, 1, 2, 3, 4, 7, 5]) let result = checkOrder(@[0, 1, 2, 3, 4, 7, 5])
if result: if result:
kout cstring"test1 - OK" results.add cstring"test1 - OK"
else: else:
kout cstring"test1 - FAIL" results.add cstring"test1 - FAIL"
# result: 0 1 2 3 4 7 5 # result: 0 1 2 3 4 7 5
proc test1() = proc test1() =
kout cstring"test1 started" results.add cstring"test1 started"
entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ] entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ]
entries.insert(cstring("7"), 5) entries.insert(cstring("7"), 5)
redraw() redraw()
@ -40,13 +41,13 @@ proc test1() =
proc check2() = proc check2() =
let result = checkOrder(@[8, 0, 1, 2, 3, 4, 7, 5]) let result = checkOrder(@[8, 0, 1, 2, 3, 4, 7, 5])
if result: if result:
kout cstring"test1 - OK" results.add cstring"test1 - OK"
else: else:
kout cstring"test2 - FAIL" results.add cstring"test2 - FAIL"
# result: 8 0 1 2 3 4 7 5 # result: 8 0 1 2 3 4 7 5
proc test2() = proc test2() =
kout cstring"test2 started" results.add cstring"test2 started"
entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ] entries = @[cstring("0"), cstring("1"), cstring("2"), cstring("3"), cstring("4"), cstring("5") ]
entries.insert(cstring("7"), 5) entries.insert(cstring("7"), 5)
entries.insert(cstring("8"), 0) entries.insert(cstring("8"), 0)
@ -56,13 +57,13 @@ proc test2() =
proc check3() = proc check3() =
let result = checkOrder(@[2, 3, 4, 1]) let result = checkOrder(@[2, 3, 4, 1])
if result: if result:
kout cstring"test3 - OK" results.add cstring"test3 - OK"
else: else:
kout cstring"test3 - FAIL" results.add cstring"test3 - FAIL"
# result: 2 3 4 1 # result: 2 3 4 1
proc test3() = proc test3() =
kout cstring"test3 started" results.add cstring"test3 started"
entries = @[cstring("2"), cstring("3"), cstring("4"), cstring("1") ] entries = @[cstring("2"), cstring("3"), cstring("4"), cstring("1") ]
redraw() redraw()
timeout = setTimeout(check3, 20) timeout = setTimeout(check3, 20)
@ -70,13 +71,13 @@ proc test3() =
proc check4() = proc check4() =
let result = checkOrder(@[5, 6, 7, 8]) let result = checkOrder(@[5, 6, 7, 8])
if result: if result:
kout cstring"test4 - OK" results.add cstring"test4 - OK"
else: else:
kout cstring"test4 - FAIL" results.add cstring"test4 - FAIL"
# result: 5 6 7 8 # result: 5 6 7 8
proc test4() = proc test4() =
kout cstring"test4 started" results.add cstring"test4 started"
entries = @[cstring("5"), cstring("6"), cstring("7"), cstring("8") ] entries = @[cstring("5"), cstring("6"), cstring("7"), cstring("8") ]
redraw() redraw()
timeout = setTimeout(check4, 20) timeout = setTimeout(check4, 20)
@ -84,13 +85,13 @@ proc test4() =
proc check5() = proc check5() =
let result = checkOrder(@[0, 1, 3, 5, 4, 5]) let result = checkOrder(@[0, 1, 3, 5, 4, 5])
if result: if result:
kout cstring"test5 - OK" results.add cstring"test5 - OK"
else: else:
kout cstring"test5 - FAIL" results.add cstring"test5 - FAIL"
# result: 0 1 3 5 4 5 # result: 0 1 3 5 4 5
proc test5() = proc test5() =
kout cstring"test5 started" results.add cstring"test5 started"
entries = @[cstring("0"), cstring("1"), cstring("3"), cstring("5"), cstring("4"), cstring("5") ] entries = @[cstring("0"), cstring("1"), cstring("3"), cstring("5"), cstring("4"), cstring("5") ]
redraw() redraw()
timeout = setTimeout(check5, 20) timeout = setTimeout(check5, 20)
@ -98,13 +99,13 @@ proc test5() =
proc check6() = proc check6() =
let result = checkOrder(@[]) let result = checkOrder(@[])
if result: if result:
kout cstring"test6 - OK" results.add cstring"test6 - OK"
else: else:
kout cstring"test6 - FAIL" results.add cstring"test6 - FAIL"
# result: empty # result: empty
proc test6() = proc test6() =
kout cstring"test6 started" results.add cstring"test6 started"
entries = @[] entries = @[]
redraw() redraw()
timeout = setTimeout(check6, 20) timeout = setTimeout(check6, 20)
@ -112,13 +113,14 @@ proc test6() =
proc check7() = proc check7() =
let result = checkOrder(@[2]) let result = checkOrder(@[2])
if result: if result:
kout cstring"test7 - OK" results.add cstring"test7 - OK"
else: else:
kout cstring"test7 - FAIL" results.add cstring"test7 - FAIL"
redraw()
# result: 2 # result: 2
proc test7() = proc test7() =
kout cstring"test7 started" results.add cstring"test7 started"
entries = @[cstring("2")] entries = @[cstring("2")]
redraw() redraw()
timeout = setTimeout(check7, 20) timeout = setTimeout(check7, 20)
@ -133,6 +135,9 @@ proc createDom(): VNode =
ul(id="ul"): ul(id="ul"):
for e in entries: for e in entries:
createEntry(parseInt(e)) createEntry(parseInt(e))
for r in results:
tdiv:
text r
setRenderer createDom setRenderer createDom