Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function overloading issue #63

Closed
o3o opened this issue Apr 11, 2017 · 1 comment
Closed

Function overloading issue #63

o3o opened this issue Apr 11, 2017 · 1 comment

Comments

@o3o
Copy link
Contributor

o3o commented Apr 11, 2017

I have:

interface IChannel {
   ubyte[] send(const(ubyte[]) msg);
   string send(string msg);
}
class Channel: IChannel {
   ubyte[] send(const(ubyte[]) msg) {
      return [0];
   }
   string send(string msg) {
      return "foo";
   }
}
class Client {
   private IChannel chan;
   this(IChannel chan) {
      assert(chan !is null);
      this.chan = chan;
   }
   void use() {
      const(ubyte[]) buf = [0, 1, 2];
      chan.send(buf);
   }
}
unittest {
   auto chan = mock!IChannel;
   const(ubyte[]) buf = [0, 1, 2];
   chan.expect!"send"(buf);

   auto c = new Client(chan);
   c.use();
   chan.verify();
}
$ dub test 
./../../.dub/packages/unit-threaded-0.7.13/unit-threaded/source/unit_threaded/mock.d(158,5): Error: class unit_threaded.mock.Mock!(IChannel).Mock.MockAbstract interface function 'string send(string msg)' is not implemented

If I change

string send(string msg) {

to

string sendMsg(string msg) {

it works.

Thank you

@o3o
Copy link
Contributor Author

o3o commented Apr 13, 2017

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant