diff options
author | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
commit | 20b5f31c03fb556ec0aa2428a40adbac004d8987 (patch) | |
tree | 58086941e7d6bb8f480ca1173a95722ada9435b2 /tests/stdlib/tmath2.nim | |
parent | 51ee524109cf7e3e86c676bc1676063a01bfd979 (diff) | |
download | Nim-20b5f31c03fb556ec0aa2428a40adbac004d8987.tar.gz |
new tester; all tests categorized
Diffstat (limited to 'tests/stdlib/tmath2.nim')
-rw-r--r-- | tests/stdlib/tmath2.nim | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/stdlib/tmath2.nim b/tests/stdlib/tmath2.nim new file mode 100644 index 000000000..6a1dae54d --- /dev/null +++ b/tests/stdlib/tmath2.nim @@ -0,0 +1,85 @@ +# tests for the interpreter + +proc loops(a: var int) = + nil + #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 heißt 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() |