tests: Trim .nim files trailing whitespace

via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
This commit is contained in:
Adam Strzelecki 2015-09-04 23:04:32 +02:00
commit e80465dacf
372 changed files with 4486 additions and 4486 deletions

View file

@ -3,7 +3,7 @@ include nre
suite "captures":
test "map capture names to numbers":
check(getNameToNumberTable(re("(?<v1>1(?<v2>2(?<v3>3))(?'v4'4))()")) ==
check(getNameToNumberTable(re("(?<v1>1(?<v2>2(?<v3>3))(?'v4'4))()")) ==
{ "v1" : 0, "v2" : 1, "v3" : 2, "v4" : 3 }.toTable())
test "capture bounds are correct":

View file

@ -8,4 +8,4 @@ doAssert product(@[@[1,2], @[3,4], @[5,6]]) == @[@[2,4,6],@[1,4,6],@[2,3,6],@[1,
doAssert product(@[@[1,2], @[]]) == newSeq[seq[int]](), "two elements, but one empty"
doAssert lowerBound([1,2,4], 3, system.cmp[int]) == 2
doAssert lowerBound([1,2,2,3], 4, system.cmp[int]) == 4
doAssert lowerBound([1,2,3,10], 11) == 4
doAssert lowerBound([1,2,3,10], 11) == 4

View file

@ -22,7 +22,7 @@ when isMainModule:
for w in r.items:
echo w
for w in r.itemsWithPrefix("de"):
echo w

View file

@ -2,11 +2,11 @@ discard """
file: "tformat.nim"
output: "Hi Andreas! How do you feel, Rumpf?"
"""
# Tests the new format proc (including the & and &= operators)
import strutils
echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"])
#OUT Hi Andreas! How do you feel, Rumpf?
# Tests the new format proc (including the & and &= operators)
import strutils
echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"])
#OUT Hi Andreas! How do you feel, Rumpf?

View file

@ -1,7 +1,7 @@
# test the file-IO
proc main() =
for line in lines("thello.nim"):
writeLine(stdout, line)
main()
# test the file-IO
proc main() =
for line in lines("thello.nim"):
writeLine(stdout, line)
main()

View file

@ -11,14 +11,14 @@ block SinglyLinkedListTest1:
var L: TSinglyLinkedList[int]
for d in items(data): L.prepend(d)
assert($L == "[6, 5, 4, 3, 2, 1]")
assert(4 in L)
block SinglyLinkedListTest2:
var L: TSinglyLinkedList[string]
for d in items(data): L.prepend($d)
assert($L == "[6, 5, 4, 3, 2, 1]")
assert("4" in L)
@ -28,7 +28,7 @@ block DoublyLinkedListTest1:
for d in items(data): L.append(d)
L.remove(L.find(1))
assert($L == "[6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]")
assert(4 in L)
block SinglyLinkedRingTest1:
@ -39,7 +39,7 @@ block SinglyLinkedRingTest1:
assert($L == "[4, 4]")
assert(4 in L)
block DoublyLinkedRingTest1:
var L: TDoublyLinkedRing[int]
@ -49,7 +49,7 @@ block DoublyLinkedRingTest1:
assert($L == "[4, 4]")
assert(4 in L)
L.append(3)
L.append(5)
assert($L == "[4, 4, 3, 5]")
@ -60,7 +60,7 @@ block DoublyLinkedRingTest1:
L.remove(L.find(4))
assert($L == "[]")
assert(4 notin L)
echo "true"

View file

@ -25,7 +25,7 @@ type
help: string
else:
discard
PNode = ref TNode
TNode = object
next, prev: PNode

View file

@ -23,13 +23,13 @@ suite "random int":
rand = random(100..1000)
check rand < 1000
check rand >= 100
test "randomize() again gives new numbers":
test "randomize() again gives new numbers":
randomize()
var rand1 = random(1000000)
randomize()
var rand2 = random(1000000)
check rand1 != rand2
suite "random float":
test "there might be some randomness":
@ -52,7 +52,7 @@ suite "random float":
rand = random(100.0..1000.0)
check rand < 1000.0
check rand >= 100.0
test "randomize() again gives new numbers":
test "randomize() again gives new numbers":
randomize()
var rand1:float = random(1000000.0)
randomize()

View file

@ -1,85 +1,85 @@
# tests for the interpreter
proc loops(a: var int) =
discard
#var
# b: int
#b = glob
#while b != 0:
# b = b + 1
#a = b
proc mymax(a, b: int): int =
#loops(result)
result = a
if b > a: result = b
proc test(a, b: int) =
var
x, y: int
x = 0
y = 7
if x == a + b * 3 - 7 or
x == 8 or
x == y and y > -56 and y < 699:
y = 0
elif y == 78 and x == 0:
y = 1
elif y == 0 and x == 0:
y = 2
else:
y = 3
type
TTokType = enum
tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf,
tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto
proc testCase(t: TTokType): int =
case t
of tkNil, tkType, tkConst: result = 0
of tkVar: result = 1
of tkSymbol: result = 2
of tkIf..tkFor: result = 3
of tkLoop: result = 56
else: result = -1
test(0, 9) # test the call
proc TestLoops() =
var
i, j: int
while i >= 0:
if i mod 3 == 0:
break
i = i + 1
while j == 13:
j = 13
break
break
while true:
break
var
glob: int
a: array [0..5, int]
proc main() =
#glob = 0
#loops( glob )
var
res: int
s: string
#write(stdout, mymax(23, 45))
write(stdout, "Hallo! Wie heisst du? ")
s = readLine(stdin)
# test the case statement
case s
of "Andreas": write(stdout, "Du bist mein Meister!\n")
of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n")
else: write(stdout, "ich kenne dich nicht!\n")
write(stdout, "Du heisst " & s & "\n")
main()
# tests for the interpreter
proc loops(a: var int) =
discard
#var
# b: int
#b = glob
#while b != 0:
# b = b + 1
#a = b
proc mymax(a, b: int): int =
#loops(result)
result = a
if b > a: result = b
proc test(a, b: int) =
var
x, y: int
x = 0
y = 7
if x == a + b * 3 - 7 or
x == 8 or
x == y and y > -56 and y < 699:
y = 0
elif y == 78 and x == 0:
y = 1
elif y == 0 and x == 0:
y = 2
else:
y = 3
type
TTokType = enum
tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf,
tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto
proc testCase(t: TTokType): int =
case t
of tkNil, tkType, tkConst: result = 0
of tkVar: result = 1
of tkSymbol: result = 2
of tkIf..tkFor: result = 3
of tkLoop: result = 56
else: result = -1
test(0, 9) # test the call
proc TestLoops() =
var
i, j: int
while i >= 0:
if i mod 3 == 0:
break
i = i + 1
while j == 13:
j = 13
break
break
while true:
break
var
glob: int
a: array [0..5, int]
proc main() =
#glob = 0
#loops( glob )
var
res: int
s: string
#write(stdout, mymax(23, 45))
write(stdout, "Hallo! Wie heisst du? ")
s = readLine(stdin)
# test the case statement
case s
of "Andreas": write(stdout, "Du bist mein Meister!\n")
of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n")
else: write(stdout, "ich kenne dich nicht!\n")
write(stdout, "Du heisst " & s & "\n")
main()

View file

@ -2,9 +2,9 @@
import os
proc walkDirTree(root: string) =
proc walkDirTree(root: string) =
for k, f in walkDir(root):
case k
case k
of pcFile, pcLinkToFile: echo(f)
of pcDir: walkDirTree(f)
of pcLinkToDir: discard

View file

@ -14,7 +14,7 @@ var TimeToWait = 5000
while process.running() and TimeToWait > 0:
sleep(100)
TimeToWait = TimeToWait - 100
if process.running():
echo("FAILED")
else:

View file

@ -1,7 +1,7 @@
import
os, parsecfg, strutils, streams
var f = newFileStream(paramStr(1), fmRead)
if f != nil:
var p: TCfgParser
@ -9,7 +9,7 @@ if f != nil:
while true:
var e = next(p)
case e.kind
of cfgEof:
of cfgEof:
echo("EOF!")
break
of cfgSectionStart: ## a ``[section]`` has been parsed

View file

@ -1,6 +1,6 @@
# Test the new beforeQuit variable:
proc myExit() {.noconv.} =
write(stdout, "just exiting...\n")
addQuitProc(myExit)
# Test the new beforeQuit variable:
proc myExit() {.noconv.} =
write(stdout, "just exiting...\n")
addQuitProc(myExit)

View file

@ -2,30 +2,30 @@ discard """
file: "tregex.nim"
output: "key: keyAYes!"
"""
# Test the new regular expression module
# which is based on the PCRE library
# Test the new regular expression module
# which is based on the PCRE library
when defined(powerpc64):
# cheat as our powerpc test machine has no PCRE installed:
echo "key: keyAYes!"
else:
import
re
if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)":
write(stdout, "key: ", matches[0])
elif "# comment!" =~ re.re"\s*(\#.*)":
# test re.re"" syntax
echo("comment: ", matches[0])
else:
echo("Bug!")
if "Username".match(re"[A-Za-z]+"):
echo("Yes!")
else:
echo("Bug!")
#OUT key: keyAYes!
else:
import
re
if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)":
write(stdout, "key: ", matches[0])
elif "# comment!" =~ re.re"\s*(\#.*)":
# test re.re"" syntax
echo("comment: ", matches[0])
else:
echo("Bug!")
if "Username".match(re"[A-Za-z]+"):
echo("Yes!")
else:
echo("Bug!")
#OUT key: keyAYes!

View file

@ -2,26 +2,26 @@ discard """
file: "treguse.nim"
output: "055this should be the casehugh"
"""
# Test the register usage of the virtual machine and
# the blocks in var statements
proc main(a, b: int) =
var x = 0
write(stdout, x)
if x == 0:
var y = 55
write(stdout, y)
write(stdout, "this should be the case")
var input = "<no input>"
if input == "Andreas":
write(stdout, "wow")
else:
write(stdout, "hugh")
else:
var z = 66
write(stdout, z) # "bug!")
main(45, 1000)
#OUT 055this should be the casehugh
# Test the register usage of the virtual machine and
# the blocks in var statements
proc main(a, b: int) =
var x = 0
write(stdout, x)
if x == 0:
var y = 55
write(stdout, y)
write(stdout, "this should be the case")
var input = "<no input>"
if input == "Andreas":
write(stdout, "wow")
else:
write(stdout, "hugh")
else:
var z = 66
write(stdout, z) # "bug!")
main(45, 1000)
#OUT 055this should be the casehugh

View file

@ -6,7 +6,7 @@ discard """
type
TEnum = enum
a, b
var val = {a, b}
stdout.write(repr(val))
stdout.writeLine(repr({'a'..'z', 'A'..'Z'}))

View file

@ -1,32 +1,32 @@
# test the new "repr" built-in proc
type
TEnum = enum
en1, en2, en3, en4, en5, en6
TPoint {.final.} = object
x, y, z: int
s: array [0..1, string]
e: TEnum
var
p: TPoint
q: ref TPoint
s: seq[ref TPoint]
p.x = 0
p.y = 13
p.z = 45
p.s[0] = "abc"
p.s[1] = "xyz"
p.e = en6
new(q)
q[] = p
s = @[q, q, q, q]
writeLine(stdout, repr(p))
writeLine(stdout, repr(q))
writeLine(stdout, repr(s))
writeLine(stdout, repr(en4))
# test the new "repr" built-in proc
type
TEnum = enum
en1, en2, en3, en4, en5, en6
TPoint {.final.} = object
x, y, z: int
s: array [0..1, string]
e: TEnum
var
p: TPoint
q: ref TPoint
s: seq[ref TPoint]
p.x = 0
p.y = 13
p.z = 45
p.s[0] = "abc"
p.s[1] = "xyz"
p.e = en6
new(q)
q[] = p
s = @[q, q, q, q]
writeLine(stdout, repr(p))
writeLine(stdout, repr(q))
writeLine(stdout, repr(s))
writeLine(stdout, repr(en4))

View file

@ -13,7 +13,7 @@ if s == "#abc#xy#z":
echo "true"
else:
echo "false"
#OUT true

View file

@ -8,7 +8,7 @@ type
TRadixNodeLinear = object of TRadixNode
len: int8
keys: array [0..31, char]
vals: array [0..31, PRadixNode]
vals: array [0..31, PRadixNode]
TRadixNodeFull = object of TRadixNode
b: array [char, PRadixNode]
TRadixNodeLeaf = object of TRadixNode
@ -16,7 +16,7 @@ type
PRadixNodeLinear = ref TRadixNodeLinear
PRadixNodeFull = ref TRadixNodeFull
PRadixNodeLeaf = ref TRadixNodeLeaf
proc search(r: PRadixNode, s: string): PRadixNode =
var r = r
var i = 0
@ -52,7 +52,7 @@ proc contains*(r: PRadixNode, s: string): bool =
proc testOrincl*(r: var PRadixNode, s: string): bool =
nil
proc incl*(r: var PRadixNode, s: string) = discard testOrIncl(r, s)
proc excl*(r: var PRadixNode, s: string) =

View file

@ -4,7 +4,7 @@ var tab = newStringTable({"key1": "val1", "key2": "val2"},
modeStyleInsensitive)
for i in 0..80:
tab["key_" & $i] = "value" & $i
for key, val in pairs(tab):
writeLine(stdout, key, ": ", val)
writeLine(stdout, "length of table ", $tab.len)

View file

@ -1,6 +1,6 @@
# test the new time module
import
times
write(stdout, $getTime())
# test the new time module
import
times
write(stdout, $getTime())

View file

@ -1,13 +1,13 @@
# iterate over all files with a given filter:
import
"../../lib/pure/os.nim", ../../ lib / pure / times
proc main(filter: string) =
for filename in walkFiles(filter):
writeLine(stdout, filename)
for key, val in envPairs():
writeLine(stdout, key & '=' & val)
main("*.nim")
# iterate over all files with a given filter:
import
"../../lib/pure/os.nim", ../../ lib / pure / times
proc main(filter: string) =
for filename in walkFiles(filter):
writeLine(stdout, filename)
for key, val in envPairs():
writeLine(stdout, key & '=' & val)
main("*.nim")