diff options
author | Araq <rumpf_a@web.de> | 2014-11-03 22:50:55 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-11-03 22:50:55 +0100 |
commit | a53e97fc892d8f2d5fc8b8abbdd7c25e4bb2f6cb (patch) | |
tree | 47f1f506408d2837e1ab5ab7f81c37f05a848706 /tests | |
parent | 8853023fd8c0ecd241b22a674db62723f4bf0305 (diff) | |
parent | 0bfa26c2138201dce539efae594e7eef1a7f25a3 (diff) | |
download | Nim-a53e97fc892d8f2d5fc8b8abbdd7c25e4bb2f6cb.tar.gz |
Merge branch 'devel' into bigbreak
Conflicts: lib/pure/osproc.nim
Diffstat (limited to 'tests')
-rw-r--r-- | tests/method/tmproto.nim | 25 | ||||
-rw-r--r-- | tests/method/trecmeth.nim | 22 | ||||
-rw-r--r-- | tests/stdlib/tosprocterminate.nim | 21 |
3 files changed, 68 insertions, 0 deletions
diff --git a/tests/method/tmproto.nim b/tests/method/tmproto.nim new file mode 100644 index 000000000..5d75cff1a --- /dev/null +++ b/tests/method/tmproto.nim @@ -0,0 +1,25 @@ +type + Obj1 = ref object {.inheritable.} + Obj2 = ref object of Obj1 + +method beta(x: Obj1): int + +proc delta(x: Obj2): int = + beta(x) + +method beta(x: Obj2): int + +proc alpha(x: Obj1): int = + beta(x) + +method beta(x: Obj1): int = 1 +method beta(x: Obj2): int = 2 + +proc gamma(x: Obj1): int = + beta(x) + +doAssert alpha(Obj1()) == 1 +doAssert gamma(Obj1()) == 1 +doAssert alpha(Obj2()) == 2 +doAssert gamma(Obj2()) == 2 +doAssert delta(Obj2()) == 2 diff --git a/tests/method/trecmeth.nim b/tests/method/trecmeth.nim new file mode 100644 index 000000000..32f620f15 --- /dev/null +++ b/tests/method/trecmeth.nim @@ -0,0 +1,22 @@ +# Note: We only compile this to verify that code generation +# for recursive methods works, no code is being executed + +type + Obj = ref object of TObject + +# Mutual recursion + +method alpha(x: Obj) +method beta(x: Obj) + +method alpha(x: Obj) = + beta(x) + +method beta(x: Obj) = + alpha(x) + +# Simple recursion + +method gamma(x: Obj) = + gamma(x) + diff --git a/tests/stdlib/tosprocterminate.nim b/tests/stdlib/tosprocterminate.nim new file mode 100644 index 000000000..fd044414c --- /dev/null +++ b/tests/stdlib/tosprocterminate.nim @@ -0,0 +1,21 @@ +import os, osproc + +when defined(Windows): + const ProgramWhichDoesNotEnd = "notepad" +else: + const ProgramWhichDoesNotEnd = "/bin/sh" + +echo("starting " & ProgramWhichDoesNotEnd) +var process = startProcess(ProgramWhichDoesNotEnd) +sleep(500) +echo("stopping process") +process.terminate() +var TimeToWait = 5000 +while process.running() and TimeToWait > 0: + sleep(100) + TimeToWait = TimeToWait - 100 + +if process.running(): + echo("FAILED") +else: + echo("SUCCESS") |