PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ruby/mark_function/runme.rb

#
Ruby | 23 lines | 12 code | 6 blank | 5 comment | 2 complexity | 766db0b26260dbdfb5c76cfc9279a961 MD5 | raw file
 1require 'example'
 2
 3# create a zoo
 4zoo = Example::Zoo.new
 5
 6begin
 7  # Add in an couple of animals
 8  tiger1 = Example::Animal.new("tiger1")
 9  zoo.add_animal(tiger1)
10  
11  # unset variables to force gc
12  tiger = nil
13end
14
15GC.start
16
17#  Now get the tiger again
18tiger2 = zoo.get_animal(0)
19
20# Call a method to verify the animal is still valid and not gc'ed
21if tiger2.get_name != "tiger1"
22    raise RuntimeError, "Wrong animal name"
23end