Sha256: 2dba11a8e70f397805e3565fae95db1d47dfde35d6d40715e49f94d87f08f6c1

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'test_helper'

describe "Extension with overloaded methods" do

  specify "should have all functions available" do
    Extension.new "overload" do |e|
      e.sources full_dir("headers/overload.h")
      node = e.namespace "overload"
      mathy = node.classes("Mathy")
      mathy.methods("times")[0].wrap_as("times")

      mathy.use_constructor(
        mathy.constructors.find(:arguments => [:int])
      )

      mathy.methods("constMethod").find(:arguments => ["std::string"]).wrap_as("const_method_string")
    end

    require 'overload'

    #Constructor overloading is broken in rice
    #math = Mathy.new
    math = Mathy.new(1)

    math.times.should == 1
    math.times_1(3).should == 3
    math.times_2(3,2).should == 6
    math.times_3(3,2,3).should == 18

    math.nothing_0
    math.nothing_1(1)

    # Should properly handle const overloads as well
    math.const_method_0(1)
    math.const_method_1(1)
    math.const_method_string("love")
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbplusplus-1.4.0 test/overloading_test.rb