diff options
author | cooldome <cdome@bk.ru> | 2018-10-11 08:54:50 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-11 09:54:50 +0200 |
commit | 7a5b614edc148a2b8fafecacecd6949a0744e8b3 (patch) | |
tree | c362cc8a84e06eeffc53a3bebc17cfd2edc380d5 /tests | |
parent | a58c982a494fbc8712067828f53b5c58ab6b3279 (diff) | |
download | Nim-7a5b614edc148a2b8fafecacecd6949a0744e8b3.tar.gz |
fixes #9297 (#9298)
* fixes #9297 * improve spacing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ccgbugs/tcgbug.nim | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/ccgbugs/tcgbug.nim b/tests/ccgbugs/tcgbug.nim index 1c6466c87..ffaa91ff3 100644 --- a/tests/ccgbugs/tcgbug.nim +++ b/tests/ccgbugs/tcgbug.nim @@ -1,6 +1,8 @@ discard """ file: "tcgbug.nim" - output: "success" + output: '''success +M1 M2 +''' """ type @@ -36,3 +38,41 @@ type var k = PFuture[void]() + +##bug #9297 +import strutils + +type + MyKind = enum + M1, M2, M3 + + MyObject {.exportc: "ExtObject"} = object + case kind: MyKind + of M1: a:int + of M2: b:float + of M3: c:cstring + + MyObjectRef {.exportc: "ExtObject2"} = ref object + case kind: MyKind + of M1: a:int + of M2: b:float + of M3: c:cstring + +proc newMyObject(kind: MyKind, val: string): MyObject = + result.kind = kind + + case kind + of M1: result.a = parseInt(val) + of M2: result.b = parseFloat(val) + of M3: result.c = val + +proc newMyObjectRef(kind: MyKind, val: string): MyObjectRef = + new(result) + result.kind = kind + case kind + of M1: result.a = parseInt(val) + of M2: result.b = parseFloat(val) + of M3: result.c = val + + +echo newMyObject(M1, "2").kind, " ", newMyObjectRef(M2, "3").kind \ No newline at end of file |