diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ccgbugs/tcodegenbug1.nim | 35 | ||||
-rw-r--r-- | tests/openarray/t8259.nim | 7 | ||||
-rw-r--r-- | tests/pragmas/tcustom_pragma.nim | 2 |
3 files changed, 42 insertions, 2 deletions
diff --git a/tests/ccgbugs/tcodegenbug1.nim b/tests/ccgbugs/tcodegenbug1.nim index fce74de0c..012a4de47 100644 --- a/tests/ccgbugs/tcodegenbug1.nim +++ b/tests/ccgbugs/tcodegenbug1.nim @@ -2,7 +2,8 @@ discard """ output: '''obj = (inner: (kind: Just, id: 7)) obj.inner.id = 7 id = 7 -obj = (inner: (kind: Just, id: 7))''' +obj = (inner: (kind: Just, id: 7)) +2''' """ # bug #6960 @@ -105,3 +106,35 @@ type proc bug5137(d: MyIntDistinct) = discard d.MyInt + +#------------------------------------- +# bug #8979 + +type + MyKind = enum + Fixed, Float + + MyObject = object + someInt: int + case kind: MyKind + of Float: index: string + of Fixed: nil + + MyResult = object + val: array[0..1, string] + vis: set[0..1] + +import macros + +func myfunc(obj: MyObject): MyResult {.raises: [].} = + template index: auto = + case obj.kind: + of Float: $obj.index + of Fixed: "Fixed" + macro to_str(a: untyped): string = + result = newStrLitNode(a.repr) + result.val[0] = index + result.val[1] = to_str(obj.kind + Ola) + +let x = MyObject(someInt: 10, kind: Fixed) +echo myfunc(x).val.len diff --git a/tests/openarray/t8259.nim b/tests/openarray/t8259.nim new file mode 100644 index 000000000..40ff2b2f1 --- /dev/null +++ b/tests/openarray/t8259.nim @@ -0,0 +1,7 @@ +discard """ + line: 6 + errormsg: "invalid type: 'openarray[int]' for result" +""" + +proc foo(a: openArray[int]):auto = a +echo foo(toOpenArray([1, 2], 0, 2)) diff --git a/tests/pragmas/tcustom_pragma.nim b/tests/pragmas/tcustom_pragma.nim index d7b199a22..ae0f39631 100644 --- a/tests/pragmas/tcustom_pragma.nim +++ b/tests/pragmas/tcustom_pragma.nim @@ -22,7 +22,7 @@ import custom_pragma block: # A bit more advanced case type Subfield {.defaultValue: "catman".} = object - c {.serializationKey: "cc".}: float + c* {.serializationKey: "cc".}: float MySerializable = object a {.serializationKey"asdf", defaultValue: 5.} : int |