Sha256: 8203c7a818149176582e8adb4d226646d3ed56b402236dde6d0d4d399009ed23

Contents?: true

Size: 1013 Bytes

Versions: 21

Compression:

Stored size: 1013 Bytes

Contents

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

RSpec.describe YARD::Handlers::C::AliasHandler do
  it "allows defining of aliases (rb_define_alias)" do
    parse <<-eof
      /* FOO */
      VALUE foo(VALUE x) { int value = x; }
      void Init_Foo() {
        rb_cFoo = rb_define_class("Foo", rb_cObject);
        rb_define_method(rb_cFoo, "foo", foo, 1);
        rb_define_alias(rb_cFoo, "bar", "foo");
      }
    eof

    expect(Registry.at('Foo#bar')).to be_is_alias
    expect(Registry.at('Foo#bar').docstring).to eq 'FOO'
  end

  it "allows defining of aliases (rb_define_alias) of attributes" do
    parse <<-eof
      /* FOO */
      VALUE foo(VALUE x) { int value = x; }
      void Init_Foo() {
        rb_cFoo = rb_define_class("Foo", rb_cObject);
        rb_define_attr(rb_cFoo, "foo", 1, 0);
        rb_define_alias(rb_cFoo, "foo?", "foo");
      }
    eof

    expect(Registry.at('Foo#foo')).to be_reader
    expect(Registry.at('Foo#foo?')).to be_is_alias
  end
end

Version data entries

21 entries across 20 versions & 4 rubygems

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