summaryrefslogtreecommitdiffhomepage
path: root/spec/handlers/c/header/function_handler_spec.rb
blob: 5fc56df0afdc403114f268b4b8474252825e74f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require_relative 'spec_helper'

describe YARD::MRuby::Handlers::C::Header::FunctionHandler do
  subject{ Registry.at('mrb_foo') }
  it "should register functions" do
    header_line <<-eof
      MRB_API void mrb_foo( void );
    eof
    expect(subject).not_to be_nil
  end

  it "should find docstrings attached to functions" do
    header_line <<-eof
      /* DOCSTRING */
      MRB_API void mrb_foo( void );
    eof

    expect(subject.docstring).to eq 'DOCSTRING'
  end

  it "should store the return type" do
    header_line <<-eof
      MRB_API mrb_value mrb_foo( void );
    eof

    expect(subject.return_type).to eq 'mrb_value'
  end

  it "should store argument types" do
    header_line <<-eof
      MRB_API mrb_value mrb_foo( mrb_state *mrb, mrb_value bar );
    eof

    expect(subject.parameter_types.first.type).to eq 'mrb_state *'
    expect(subject.parameter_types.last.type).to eq 'mrb_value'
    expect(subject.parameter_types.last.name).to eq 'bar'
  end
end