PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/ruby/newobject1_runme.rb

#
Ruby | 33 lines | 11 code | 4 blank | 18 comment | 1 complexity | b6267e1d659b45ad4072c468d9ec712a MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. #!/usr/bin/env ruby
  2. #
  3. # Simple test of %newobject
  4. # * The purpose of this test is to confirm that a language module
  5. # * correctly handles the case when C++ class member functions (of both
  6. # * the static and non-static persuasion) have been tagged with the
  7. # * %newobject directive.
  8. #
  9. # Ruby's GC is somewhat broken in that it will mark some more stack space
  10. # leading to the collection of local objects to be delayed.
  11. # Thus, upon invokation, it sometimes you can wait up to several
  12. # instructions to kick in.
  13. # See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449
  14. #
  15. #
  16. #
  17. #
  18. #
  19. require 'swig_assert'
  20. require 'swig_gc'
  21. require 'newobject1'
  22. include Newobject1
  23. GC.track_class = Foo
  24. GC.start
  25. 100.times { foo1 = Foo.makeFoo; foo2 = foo1.makeMore }
  26. GC.stats if $VERBOSE
  27. swig_assert( 'Foo.fooCount == 200', binding, "but is #{Foo.fooCount}" )
  28. GC.start
  29. swig_assert( 'Foo.fooCount <= 2', binding, "but is #{Foo.fooCount}" )