Sha256: 65019eb4ff544652660cda7beaa9a05d5bc892d0535609e439a4b342f31798db

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require File.expand_path('test_helper.rb', File.dirname(__FILE__))

class ModuleBuilderTest < Test::Unit::TestCase
  context "The ModuleBuilder" do
    context "for Gtk" do
      setup do
	@mbuilder = GirFFI::ModuleBuilder.new('Gtk')
      end

      context "looking at Gtk.main" do
	setup do
	  @go = get_function_introspection_data 'Gtk', 'main'
	end

	should "build correct definition of Gtk.main" do
	  code = @mbuilder.send :function_definition, @go, Lib
	  expected = "def main\n::Lib.gtk_main\nend"
	  assert_equal cws(expected), cws(code)
	end
      end

      context "looking at Gtk.init" do
	setup do
	  @go = get_function_introspection_data 'Gtk', 'init'
	end

	should "delegate definition to FunctionDefinitionBuilder" do
	  code = @mbuilder.send :function_definition, @go, Lib
	  expected = GirFFI::FunctionDefinitionBuilder.new(@go, Lib).generate
	  assert_equal cws(expected), cws(code)
	end
      end
    end

    context "for GObject" do
      setup do
	@mbuilder = GirFFI::ModuleBuilder.new('GObject')
      end

      context "looking at GObject.signal_connect_data" do
	setup do
	  @go = get_function_introspection_data 'GObject', 'signal_connect_data'
	end

	should "delegate definition to FunctionDefinitionBuilder" do
	  code = @mbuilder.send :function_definition, @go, Lib
	  expected = GirFFI::FunctionDefinitionBuilder.new(@go, Lib).generate
	  assert_equal cws(expected), cws(code)
	end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gir_ffi-0.0.6 test/module_builder_test.rb