diff options
Diffstat (limited to 'tests/assign')
-rw-r--r-- | tests/assign/moverload_asgn2.nim | 4 | ||||
-rw-r--r-- | tests/assign/tassign.nim | 8 | ||||
-rw-r--r-- | tests/assign/tobject_assign.nim | 49 | ||||
-rw-r--r-- | tests/assign/tvariantasgn.nim | 13 |
4 files changed, 70 insertions, 4 deletions
diff --git a/tests/assign/moverload_asgn2.nim b/tests/assign/moverload_asgn2.nim index 6620adbeb..cfea48cd1 100644 --- a/tests/assign/moverload_asgn2.nim +++ b/tests/assign/moverload_asgn2.nim @@ -1,3 +1,7 @@ +discard """ + matrix: "--mm:refc" +""" + type Concrete* = object a*, b*: string diff --git a/tests/assign/tassign.nim b/tests/assign/tassign.nim index 0589b0214..fdec04d22 100644 --- a/tests/assign/tassign.nim +++ b/tests/assign/tassign.nim @@ -80,7 +80,7 @@ block tcopy: block tgenericassign: type - TAny = object {.pure.} + TAny {.pure.} = object value: pointer rawType: pointer @@ -93,9 +93,9 @@ block tgenericassign: var ret: seq[tuple[name: string, a: TAny]] = @[] for i in 0 .. 8000: var tup = ($name, newAny(nil, nil)) - assert(tup[0] == "example") + doAssert(tup[0] == "example") ret.add(tup) - assert(ret[ret.len()-1][0] == "example") + doAssert(ret[ret.len()-1][0] == "example") @@ -178,7 +178,7 @@ when false: proc `=`[T](d: var GenericT[T]; src: GenericT[T]) = shallowCopy(d.a, src.a) shallowCopy(d.b, src.b) - echo "GenericT[T] '=' ", type(T).name + echo "GenericT[T] '=' ", typeof(T).name var ag: GenericT[int] var bg: GenericT[int] diff --git a/tests/assign/tobject_assign.nim b/tests/assign/tobject_assign.nim new file mode 100644 index 000000000..8e39ead53 --- /dev/null +++ b/tests/assign/tobject_assign.nim @@ -0,0 +1,49 @@ +# bug #16706 + +block: # reduced example + type + A = object of RootObj + a0: string + B = object + b0: seq[A] + var c = newSeq[A](2) + var d = B(b0: c) + +when true: # original example + import std/[options, tables, times] + + type + Data* = object + shifts*: OrderedTable[int64, Shift] + balance*: float + + Shift* = object + quoted*: bool + date*: DateTime + description*: string + start*: Option[DateTime] + finish*: Option[DateTime] + breakTime*: Option[Duration] + rate*: float + qty: Option[float] + id*: int64 + + let shift = Shift( + quoted: true, + date: parse("2000-01-01", "yyyy-MM-dd"), + description: "abcdef", + start: none(DateTime), + finish: none(DateTime), + breakTime: none(Duration), + rate: 462.11, + qty: some(10.0), + id: getTime().toUnix() + ) + + var shifts: OrderedTable[int64, Shift] + shifts[shift.id] = shift + + discard Data( + shifts: shifts, + balance: 0.00 + ) diff --git a/tests/assign/tvariantasgn.nim b/tests/assign/tvariantasgn.nim index 1c3deeae1..4c3c38ca5 100644 --- a/tests/assign/tvariantasgn.nim +++ b/tests/assign/tvariantasgn.nim @@ -24,3 +24,16 @@ s = TAny(kind: nkInt, intVal: 78) # s = nr # works nr = s # fails! echo "came here" + +block: # bug #12464 + type + Foo = object + case isFunc: bool + of false: nil + of true: + fun: proc(): int + + const i = Foo(isFunc: false) + + let j = i + doAssert not j.isFunc |