diff options
Diffstat (limited to 'tests/thallo.nim')
-rw-r--r-- | tests/thallo.nim | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/tests/thallo.nim b/tests/thallo.nim index 47d56724b..f8d3b8a69 100644 --- a/tests/thallo.nim +++ b/tests/thallo.nim @@ -1,7 +1,11 @@ # Hallo import - os + os, strutils, macros + +type + TMyEnum = enum + meA, meB, meC, meD when isMainModule: {.hint: "this is the main file".} @@ -9,7 +13,7 @@ when isMainModule: proc fac[T](x: T): T = # test recursive generic procs if x <= 1: return 1 - else: return x * fac(x-1) + else: return x.`*`(fac(x-1)) macro macrotest(n: expr): stmt = expectKind(n, nnkCall) @@ -35,22 +39,41 @@ echo("This was compiled by Nimrod version " & system.nimrodVersion) writeln(stdout, "Hallo", " World", "!") echo(["a", "b", "c", "d"].len) -for x in items(["What's", "your", "name", "?"]): +for x in items(["What's", "your", "name", "?", ]): echo(x = x) var `name` = readLine(stdin) {.breakpoint.} echo("Hi " & thallo.name & "!\n") debug(name) -var testseq: seq[string] = @[ "a", "b", "c", "d", "e"] +var testseq: seq[string] = @[ + "a", "b", "c", "d", "e" +] echo(repr(testseq)) var dummy = "hallo" echo(copy(dummy, 2, 3)) +echo($meC) + +# test tuples: +for x, y in items([(1, 2), (3, 4), (6, 1), (5, 2)]): + echo x + echo y + +# test constant evaluation: +const + constEval = "abc".contains('b') + constEval2 = fac(7) + +echo(constEval) +echo(constEval2) +echo(1.`+`(2)) + for i in 2..6: for j in countdown(i+4, 2): echo(fac(i * j)) when isMainModule: {.hint: "this is the main file".} + |