<commit_before>require File.expand_path('test_helper.rb', File.dirname(__FILE__))
require 'gir_ffi'

class ClassBuilderTest < Test::Unit::TestCase
  context "The ClassBuilder" do
    should "use parent struct as default layout" do
      @gir = GirFFI::IRepository.default
      @gir.require 'GObject', nil

      @classbuilder = GirFFI::ClassBuilder.new 'Foo', 'Bar'

      stub(info = Object.new).parent { @gir.find_by_name 'GObject', 'Object' }
      stub(info).fields { [] }

      @classbuilder.instance_eval { @info = info }
      @classbuilder.instance_eval { @parent = info.parent }
      @classbuilder.instance_eval { @superclass = GObject::Object }

      spec = @classbuilder.send :layout_specification
      assert_equal [:parent, GObject::Object::Struct, 0], spec
    end

    context "for Gtk::Widget" do
      setup do<commit_msg>Clean up ClassBuilder test.<commit_after>require File.expand_path('test_helper.rb', File.dirname(__FILE__))
require 'gir_ffi'

class ClassBuilderTest < Test::Unit::TestCase
  context "The ClassBuilder" do
    should "use parent struct as default layout" do
      @gir = GirFFI::IRepository.default
      @gir.require 'GObject', nil

      stub(info = Object.new).parent { @gir.find_by_name 'GObject', 'Object' }
      stub(info).fields { [] }
      stub(info).type { :object }

      @classbuilder = GirFFI::ClassBuilder.new 'Foo', 'Bar'
      @classbuilder.instance_eval { @info = info }

      spec = @classbuilder.send :layout_specification
      assert_equal [:parent, GObject::Object::Struct, 0], spec
    end

    context "for Gtk::Widget" do
      setup do
{'fraction_non_alphanumeric': 0.12445550715619166, 'fraction_numerical': 0.0012445550715619166, 'mean_word_length': 3.6744186046511627, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4793332', 'n_tokens_mistral': 509, 'n_tokens_neox': 500, 'n_words': 116}