Sha256: 98a6bdf4e701e1404e758a62afdb7ee606ef09a4869e1f33c925dd8dce75f500

Contents?: true

Size: 1.2 KB

Versions: 21

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
require File.dirname(__FILE__) + "/spec_helper"

RSpec.describe YARD::Handlers::C::InitHandler do
  it "adds documentation in Init_ClassName() to ClassName" do
    parse(<<-eof)
      // Bar!
      void Init_A() {
        rb_cA = rb_define_class("A", rb_cObject);
      }
    eof
    expect(Registry.at('A').docstring).to eq 'Bar!'
  end

  it "does not add documentation if ClassName is not created in Init" do
    parse(<<-eof)
      // Bar!
      void Init_A() {
      }
    eof
    expect(Registry.at('A')).to be nil
  end

  it "does not overwrite override comment" do
    parse(<<-eof)
      /* Document-class: A
       * Foo!
       */

      // Bar!
      static SWIGEXPORT void Init_A() {
        rb_cA = rb_define_class("A", rb_cObject);
      }
    eof
    expect(Registry.at('A').docstring).to eq 'Foo!'
  end

  it "checks non-Init methods for declarations too" do
    parse(<<-eof)
      void foo(int x, int y, char *name) {
        rb_cB = rb_define_class("B", rb_cObject);
        rb_define_method(rb_cB, "foo", foo_impl, 0);
      }
    eof
    expect(Registry.at('B')).to be_a(CodeObjects::ClassObject)
    expect(Registry.at('B#foo')).to be_a(CodeObjects::MethodObject)
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

Version Path
yard-0.9.24 spec/handlers/c/init_handler_spec.rb
yard-0.9.23 spec/handlers/c/init_handler_spec.rb
yard-0.9.22 spec/handlers/c/init_handler_spec.rb
yard-0.9.21 spec/handlers/c/init_handler_spec.rb
yard-0.9.20 spec/handlers/c/init_handler_spec.rb
yard-0.9.19 spec/handlers/c/init_handler_spec.rb
yard-0.9.16 spec/handlers/c/init_handler_spec.rb
yard-0.9.15 spec/handlers/c/init_handler_spec.rb
yard-0.9.14 spec/handlers/c/init_handler_spec.rb
yard-0.9.13 spec/handlers/c/init_handler_spec.rb
yard-0.9.12 spec/handlers/c/init_handler_spec.rb
yard-0.9.11 spec/handlers/c/init_handler_spec.rb
yard-0.9.10 spec/handlers/c/init_handler_spec.rb
yard-0.9.9 spec/handlers/c/init_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/spec/handlers/c/init_handler_spec.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/spec/handlers/c/init_handler_spec.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/spec/handlers/c/init_handler_spec.rb
yard-0.9.8 spec/handlers/c/init_handler_spec.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/spec/handlers/c/init_handler_spec.rb
yard-0.9.7 spec/handlers/c/init_handler_spec.rb