diff options
author | Araq <rumpf_a@web.de> | 2010-09-20 23:54:40 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2010-09-20 23:54:40 +0200 |
commit | ea2306b301262d4010724c6db0374f5fa866ea85 (patch) | |
tree | b14aceb64e7bd088f7ec6c7da137ecc4691c14e7 /tests/accept | |
parent | 0a57f662fa6f15916caa564312a162ddb3c04883 (diff) | |
download | Nim-ea2306b301262d4010724c6db0374f5fa866ea85.tar.gz |
bugfix: finally sections are executed before return/break
Diffstat (limited to 'tests/accept')
-rw-r--r-- | tests/accept/run/mmultim3.nim | 12 | ||||
-rwxr-xr-x | tests/accept/run/spec.csv | 1 | ||||
-rw-r--r-- | tests/accept/run/tcontinuexc.nim | 6 | ||||
-rw-r--r-- | tests/accept/run/tfinally2.nim | 21 | ||||
-rw-r--r-- | tests/accept/run/tfinally3.nim | 12 | ||||
-rw-r--r-- | tests/accept/run/tmultim3.nim | 14 |
6 files changed, 64 insertions, 2 deletions
diff --git a/tests/accept/run/mmultim3.nim b/tests/accept/run/mmultim3.nim new file mode 100644 index 000000000..ca73ebea6 --- /dev/null +++ b/tests/accept/run/mmultim3.nim @@ -0,0 +1,12 @@ +type + TObj* = object + +var myObj* : ref TObj + +method test123(a : ref TObj) = + echo("Hi base!") + +proc testMyObj*() = + test123(myObj) + + diff --git a/tests/accept/run/spec.csv b/tests/accept/run/spec.csv index 66eb7eb6a..172a04464 100755 --- a/tests/accept/run/spec.csv +++ b/tests/accept/run/spec.csv @@ -16,6 +16,7 @@ tcgbug.nim; tclosure.nim;2 4 6 8 10 tcnstseq.nim;AngelikaAnneAnnaAnkaAnja tconstr2.nim;69 +tcontinuexc.nim;ECcaught tcopy.nim;TEMP=C:\Programs\xyz\bin tcurrncy.nim;25 texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13 diff --git a/tests/accept/run/tcontinuexc.nim b/tests/accept/run/tcontinuexc.nim index 97b190e3c..496ee8164 100644 --- a/tests/accept/run/tcontinuexc.nim +++ b/tests/accept/run/tcontinuexc.nim @@ -13,9 +13,11 @@ try: try: genErrors("error!") except ESomething: - echo("Error happened") - echo "came here" + stdout.write("E") + stdout.write("C") raise newException(EsomeotherErr, "bla") finally: echo "caught" +#OUT ECcaught + diff --git a/tests/accept/run/tfinally2.nim b/tests/accept/run/tfinally2.nim new file mode 100644 index 000000000..10d08e816 --- /dev/null +++ b/tests/accept/run/tfinally2.nim @@ -0,0 +1,21 @@ +# Test break in try statement: + +proc main: int = + try: + block AB: + try: + try: + break AB + finally: + stdout.write("A") + stdout.write("skipped") + finally: + block B: + stdout.write("B") + stdout.write("skipped") + stdout.write("C") + finally: + stdout.writeln("D") + +discard main() #OUT ABCD + diff --git a/tests/accept/run/tfinally3.nim b/tests/accept/run/tfinally3.nim new file mode 100644 index 000000000..e8d81c893 --- /dev/null +++ b/tests/accept/run/tfinally3.nim @@ -0,0 +1,12 @@ +# Test break in try statement: + +proc main: bool = + while true: + try: + return true + finally: + break + return false + +echo main() #OUT false + diff --git a/tests/accept/run/tmultim3.nim b/tests/accept/run/tmultim3.nim new file mode 100644 index 000000000..a3271d8d9 --- /dev/null +++ b/tests/accept/run/tmultim3.nim @@ -0,0 +1,14 @@ +import mmultim3 + +type + TBObj* = object of TObj + + +method test123(a : ref TBObj) = + echo("Hi derived!") + +var a : ref TBObj +new(a) +myObj = a +testMyObj() + |