kosi-libs / MocKMP

A mocking processor for Kotlin Multiplatform
https://kosi-libs.org/mockmp
MIT License
183 stars 12 forks source link

Is any special step should be taken to mock vararg functions? #54

Closed motorro closed 1 year ago

motorro commented 1 year ago

Hello!

I'm trying to mock the interface with the function that has a vararg argument. Is there anything special should be done to do it or is it not supported?

The interface I try to mock:

interface ResourceWrapper {
    /**
     * Returns a resource string
     */
    fun getString(resId: StringResource, vararg args: Any): String
}

Generated file:

internal class MockResourceWrapper(
  private val mocker: Mocker,
) : ResourceWrapper {
    public override fun getString(resId: StringResource, args: Any): String =
      this.mocker.register(this, "getString(dev.icerock.moko.resources.StringResource, kotlin.Any)",
      resId, args)
}

The overriden function doesn't have a vararg modifier so I get a compilation error

SalomonBrys commented 1 year ago

Vararg arguments are not supported yet. I'll work on those for next release 👍

SalomonBrys commented 1 year ago

Fix released in v1.14.0.