diff options
author | Araq <rumpf_a@web.de> | 2013-03-16 20:40:26 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-03-16 20:40:26 +0100 |
commit | d9149635393d6c2de589d645b541793da2f5cc9b (patch) | |
tree | fc8e0fd99c9beaf0a2bb6d3341c01552b0f5af29 /tests | |
parent | 7d05356df64c99a72f6caeeec5e98ca7482b2e14 (diff) | |
parent | 7304ca061159db8345ae245309274310bbfd0ab1 (diff) | |
download | Nim-d9149635393d6c2de589d645b541793da2f5cc9b.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run/tfieldindex.nim | 21 | ||||
-rwxr-xr-x | tests/run/tfinally.nim | 8 | ||||
-rwxr-xr-x | tests/run/tfinally2.nim | 17 | ||||
-rw-r--r-- | tests/specials.nim | 8 |
4 files changed, 38 insertions, 16 deletions
diff --git a/tests/run/tfieldindex.nim b/tests/run/tfieldindex.nim new file mode 100644 index 000000000..3ffa65e58 --- /dev/null +++ b/tests/run/tfieldindex.nim @@ -0,0 +1,21 @@ +discard """ + output: "1" +""" + +type + TMyTuple = tuple[a, b: int] + +proc indexOf*(t: typedesc, name: string): int {.compiletime.} = + ## takes a tuple and looks for the field by name. + ## returs index of that field. + var + d: t + i = 0 + for n, x in fieldPairs(d): + if n == name: return i + i.inc + raise newException(EInvalidValue, "No field " & name & " in type " & + astToStr(t)) + +echo TMyTuple.indexOf("b") + diff --git a/tests/run/tfinally.nim b/tests/run/tfinally.nim index 29313c3fd..273aac72b 100755 --- a/tests/run/tfinally.nim +++ b/tests/run/tfinally.nim @@ -1,6 +1,8 @@ discard """ file: "tfinally.nim" - output: "came here 3" + output: '''came +here +3''' """ # Test return in try statement: @@ -9,10 +11,10 @@ proc main: int = try: return 1 finally: - stdout.write("came ") + echo("came") return 2 finally: - stdout.write("here ") + echo("here ") return 3 echo main() #OUT came here 3 diff --git a/tests/run/tfinally2.nim b/tests/run/tfinally2.nim index 3ed212a7c..e1e8d4c7e 100755 --- a/tests/run/tfinally2.nim +++ b/tests/run/tfinally2.nim @@ -1,6 +1,9 @@ discard """ file: "tfinally2.nim" - output: "ABCD" + output: '''A +B +C +D''' """ # Test break in try statement: @@ -11,15 +14,15 @@ proc main: int = try: break AB finally: - stdout.write("A") - stdout.write("skipped") + echo("A") + echo("skipped") finally: block B: - stdout.write("B") - stdout.write("skipped") - stdout.write("C") + echo("B") + echo("skipped") + echo("C") finally: - stdout.writeln("D") + echo("D") discard main() #OUT ABCD diff --git a/tests/specials.nim b/tests/specials.nim index 1818497a4..b5c49ec3c 100644 --- a/tests/specials.nim +++ b/tests/specials.nim @@ -176,14 +176,10 @@ proc runJsTests(r: var TResults, options: string) = runSingleTest(r, filename, options & " -d:nodejs", targetJS) runSingleTest(r, filename, options & " -d:nodejs -d:release", targetJS) - # texceptions, texcpt1, texcsub, tfinally, tfinally2, - # tfinally3 for t in os.walkFiles("tests/js/t*.nim"): test(t) - test "tests/run/tactiontable" - test "tests/run/tmultim1" - test "tests/run/tmultim3" - test "tests/run/tmultim4" + for testfile in ["texceptions", "texcpt1", "texcsub", "tfinally", "tfinally2", "tfinally3", "tactiontable", "tmultim1", "tmultim3", "tmultim4"]: + test "tests/run/" & testfile & ".nim" # ------------------------- register special tests here ----------------------- proc runSpecialTests(r: var TResults, options: string) = |