Sha256: b8e6199f23c3013125be232677d1b8cdf4346e5e88284f387dc0d6518eab7399

Contents?: true

Size: 1.96 KB

Versions: 68

Compression:

Stored size: 1.96 KB

Contents

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

describe YARD::Handlers::C::ConstantHandler do
  it "should register constants" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      rb_define_const(mFoo, "FOO", ID2SYM(100));
    eof
    Registry.at('Foo::FOO').type.should == :constant
  end

  it "should look for override comments" do
    parse <<-eof
      /* Document-const: FOO
       * Document-const: Foo::BAR
       * Foo bar!
       */

      void Init_Foo() {
        mFoo = rb_define_module("Foo");
        rb_define_const(mFoo, "FOO", ID2SYM(100));
        rb_define_const(mFoo, "BAR", ID2SYM(101));
      }
    eof
    foo = Registry.at('Foo::FOO')
    foo.type.should == :constant
    foo.docstring.should == 'Foo bar!'
    foo.value.should == 'ID2SYM(100)'
    foo.file.should == '(stdin)'
    foo.line.should == 8
    bar = Registry.at('Foo::BAR')
    bar.type.should == :constant
    bar.docstring.should == 'Foo bar!'
    bar.file.should == '(stdin)'
    bar.line.should == 9
    bar.value.should == 'ID2SYM(101)'
  end

  it "should use comment attached to declaration as fallback" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      rb_define_const(mFoo, "FOO", ID2SYM(100)); // foobar!
    eof
    foo = Registry.at('Foo::FOO')
    foo.value.should == 'ID2SYM(100)'
    foo.docstring.should == 'foobar!'
  end

  it "should allow the form VALUE: DOCSTRING to document value" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100: foobar!
    eof
    foo = Registry.at('Foo::FOO')
    foo.value.should == '100'
    foo.docstring.should == 'foobar!'
  end

  it "should allow escaping of backslashes in VALUE: DOCSTRING syntax" do
    parse_init <<-eof
      mFoo = rb_define_module("Foo");
      rb_define_const(mFoo, "FOO", ID2SYM(100)); // 100\\:x\\:y: foobar:x!
    eof
    foo = Registry.at('Foo::FOO')
    foo.value.should == '100:x:y'
    foo.docstring.should == 'foobar:x!'
  end
end

Version data entries

68 entries across 52 versions & 7 rubygems

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