v2 / vlib / v / tests / options / option_auto_heap_test.v
24 lines · 19 sloc · 312 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct Teste {
2pub mut:
3 teste ?&Teste
4}
5
6fn test_main() {
7 mut a := Teste{}
8 a.teste = &a
9 dump(a) // circular
10
11 assert a.teste? == &a
12
13 mut t := ?Teste{}
14 w := dump(t) // Option(none)
15 assert w == none
16
17 mut z := ?Teste{}
18 z = Teste{}
19 z?.teste = &z
20 dump(z) // // circular
21
22 y := z?
23 assert y.teste? == &z?
24}
25