Sha256: 1b718a7b7c56d2a76c533dc02bf70ffd04962c5e08d6e90eaab37edc2da420ed

Contents?: true

Size: 1.91 KB

Versions: 63

Compression:

Stored size: 1.91 KB

Contents

require File.dirname(__FILE__) + "/spec_helper"

describe YARD::Handlers::C::ClassHandler do
  it "should register classes" do
    parse_init 'cFoo = rb_define_class("Foo", rb_cObject);'
    Registry.at('Foo').type.should == :class
  end

  it "should register classes under namespaces" do
    parse_init 'cFoo = rb_define_class_under(cBar, "Foo", rb_cObject);'
    Registry.at('Bar::Foo').type.should == :class
  end

  it "should remember symbol defined with class" do
    parse_init(<<-eof)
      cXYZ = rb_define_class("Foo", rb_cObject);
      rb_define_method(cXYZ, "bar", bar, 0);
    eof
    Registry.at('Foo').type.should == :class
    Registry.at('Foo#bar').should_not be_nil
  end

  it "should lookup superclass symbol name" do
    parse_init(<<-eof)
      cXYZ = rb_define_class("Foo", rb_cObject);
      cBar = rb_define_class("Bar", cXYZ);
    eof
    Registry.at('Bar').superclass.should == Registry.at('Foo')
  end

  it "should user superclass symbol name as proxy if not found" do
    parse_init(<<-eof)
      // cXYZ = rb_define_class("Foo", rb_cObject);
      cBar = rb_define_class("Bar", cXYZ);
    eof
    Registry.at('Bar').superclass.should == P('XYZ')
  end

  it "should not associate declaration comments as class docstring" do
    parse_init(<<-eof)
      /* Docstring! */
      cFoo = rb_define_class("Foo", cObject);
    eof
    Registry.at('Foo').docstring.should be_blank
  end

  it "should associate a file with the declaration" do
    parse_init(<<-eof)
      cFoo = rb_define_class("Foo", cObject);
    eof
    Registry.at('Foo').file.should == '(stdin)'
    Registry.at('Foo').line.should == 2
  end

  it "should properly handle Proxy superclasses" do
    parse_init <<-eof
      cFoo = rb_define_class_under(mFoo, "Bar", rb_cBar);
    eof
    Registry.at('Foo::Bar').type.should == :class
    Registry.at('Foo::Bar').superclass.should == P('Bar')
    Registry.at('Foo::Bar').superclass.type.should == :class
  end
end

Version data entries

63 entries across 49 versions & 7 rubygems

Version Path
yard-0.8.7.6 spec/handlers/c/class_handler_spec.rb
yard-0.8.7.5 spec/handlers/c/class_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
yard-0.8.7.4 spec/handlers/c/class_handler_spec.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/spec/handlers/c/class_handler_spec.rb
yard-0.8.7.3 spec/handlers/c/class_handler_spec.rb
yard-0.8.7.2 spec/handlers/c/class_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/gems/yard-0.8.7/spec/handlers/c/class_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/yard-0.8.7/spec/handlers/c/class_handler_spec.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/yard-0.8.7/spec/handlers/c/class_handler_spec.rb
yard-0.8.7.1 spec/handlers/c/class_handler_spec.rb