PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/go/refcount_runme.go

#
Go | 32 lines | 15 code | 7 blank | 10 comment | 4 complexity | d206a059d1e47fe819af21fe0349ff76 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. package main
  2. import . "./refcount"
  3. // very innocent example
  4. func main() {
  5. a := NewA3()
  6. _ = NewB(a)
  7. b2 := BCreate(a)
  8. if a.Ref_count() != 3 {
  9. panic("This program will crash... now")
  10. }
  11. rca := b2.Get_rca()
  12. // _ = BCreate(rca)
  13. _ = rca
  14. if a.Ref_count() != 4 {
  15. panic("This program will crash... now")
  16. }
  17. /* Requires smart pointer support.
  18. v := NewVector_A(2)
  19. v.Set(0, a)
  20. v.Set(1, a)
  21. _ = v.Get(0)
  22. DeleteVector_A(v)
  23. */
  24. }