File: test-gc.rb

package info (click to toggle)
ruby-gnome 4.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 26,648 kB
  • sloc: ruby: 67,701; ansic: 67,431; xml: 350; sh: 201; cpp: 45; makefile: 42
file content (29 lines) | stat: -rw-r--r-- 678 bytes parent folder | download
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
class TestGC < Test::Unit::TestCase
  priority :must
  def test_closure
    klass = Class.new
    n_tries = 100
    n_tries.times do
      widget = Gtk::Box.new(:horizontal)
      closed_object = klass.new
      widget.signal_connect("hide") {p closed_object}
    end
    GC.start
    n_closed_objects = ObjectSpace.each_object(klass) {}
    assert do
      n_closed_objects < n_tries
    end
  end

  def test_inheritance_and_gc
    button = Class.new(Gtk::Button)
    box = Gtk::Box.new(:horizontal)
    n = 10
    n.times do
      box.append(button.new)
    end
    GC.start
    assert_equal([button] * n,
                 box.children.collect {|item| item.class})
  end
end