[cairo-commit] rcairo/test run-test.rb, 1.2, 1.3 test_context.rb, NONE, 1.1

Kouhei Sutou commit at pdx.freedesktop.org
Mon Aug 11 05:53:35 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/test
In directory kemper:/tmp/cvs-serv19648/test

Modified Files:
	run-test.rb 
Added Files:
	test_context.rb 
Log Message:
        * test/test_context.rb: add.

        * test/run-test.rb: don't use at_exit test runner because rcairo
        uses at_exit based GC guard mechanism.

        * src/rb_cairo_context.c: free all alive Cairo::Context before
        stop GC like Cairo::Surface.

        * src/rb_cairo_private.[ch]: abstract explicit free before stop GC
        used by Cairo::Surface.

        * src/rb_cairo_surface.c: use abstracted explicit free before stop
        GC.


Index: run-test.rb
===================================================================
RCS file: /cvs/cairo/rcairo/test/run-test.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- run-test.rb	9 Apr 2008 06:15:42 -0000	1.2
+++ run-test.rb	11 Aug 2008 12:53:32 -0000	1.3
@@ -13,3 +13,5 @@
 Dir.glob("test/**/test_*.rb") do |file|
   require file.sub(/\.rb$/, '')
 end
+
+exit Test::Unit::AutoRunner.run(false)

--- NEW FILE: test_context.rb ---
require 'cairo'
require 'stringio'

class ContextTest < Test::Unit::TestCase
  def setup
    @output = StringIO.new
    @surface = Cairo::PDFSurface.new(@output, 10, 10)
  end

  def test_new_and_destroy
    context = Cairo::Context.new(@surface)
    @surface.destroy
    assert_no_match(/%%EOF\s*\z/m, @output.string)
    context.destroy
    assert_match(/%%EOF\s*\z/m, @output.string)
  end

  def test_new_with_block
    Cairo::Context.new(@surface) do |context|
      @surface.destroy
      assert_no_match(/%%EOF\s*\z/m, @output.string)
    end
    assert_match(/%%EOF\s*\z/m, @output.string)
  end

  def test_new_with_block_and_destroy
    assert_nothing_raised do
      Cairo::Context.new(@surface) do |context|
        context.destroy
      end
    end
  end
end



More information about the cairo-commit mailing list