summary refs log tree commit diff stats
path: root/tests/assign/tobjasgn.nim
blob: 5f411063f272781194fa6e5ddc146b30475d11a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
discard """
  output: '''0
pre test a:test b:1 c:2 haha:3
assignment test a:test b:1 c:2 haha:3
'''
"""

type TSomeObj = object of TObject
  Variable: int
 
var a = TSomeObj()
 
echo a.Variable.`$`

# bug #575

type
  Something = object of Tobject
    a: string
    b, c: int32

type
  Other = object of Something
    haha: int

proc `$`(x: Other): string =
  result = "a:" & x.a & " b:" & $x.b & " c:" & $x.c & " haha:" & $x.haha

var
  t: Other

t.a = "test"
t.b = 1
t.c = 2
t.haha = 3

echo "pre test ", $t
var x = t
echo "assignment test ", x