dart-archive / mock

A library for mocking classes - DEPRECATED
https://pub.dartlang.org/packages/mock
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Support named arguments in mock proxies #11

Closed DartBot closed 9 years ago

DartBot commented 9 years ago

Originally opened as dart-lang/sdk#9613

This issue was originally filed by iz...@gmail.com


In line 1338 of mock.dart there's the next TODO:

          // TODO(gram): Replace all this with:           // var rtn = invocation.invokeOn(value);           // once that is supported.

I believe invokeOn is already implemented. Can you remove the TODO and implement it correctly? Otherwise there's no way to mock method with named arguments.

Thanks.

DartBot commented 9 years ago

This comment was originally written by iz...@gmail.com


I have patched my local SDK and have found that this TODO is wrong.

invokeOn(value) will apply the InvocationMirror to the proxy closure which, of course, has not the same signature as the InvocationMirror.

The correct way to do this would be something like:

    var args = invocation.positionalArguments;     var nargs = invocation.namedArguments;     var mirror = reflect(closure);     mirror.invoke( "THIS IS THE MEMBER NAME, BUT IN THIS CASE THERE'S NO MEMBER NAME AS THIS IS A CLOSURE", args, nargs );

Which, anyway, doesn't work yet as invoke() with named arguments is not yet supported.

Can we please rename this bug to "support named arguments in mock proxies" and leave it open for further reference?

DartBot commented 9 years ago

Comment by gramster


Changed the title to: "Support named arguments in mock proxies".

DartBot commented 9 years ago

Comment by anders-sandholm


cc @gramster. Added Area-Library, Triaged labels.

DartBot commented 9 years ago

Comment by sigmundch


cc @kevmoo.

DartBot commented 9 years ago

Comment by lrhn


Removed Area-Library label. Added Area-Pkg, Pkg-Mock labels.

DartBot commented 9 years ago

Comment by kevmoo


dart-lang/sdk@34dc57038895bf68b3d039798ed212f2f5a992f6


Added Fixed label.