Skip to content

Commit 688140b

Browse files
committed
test: Add coverage for type-function.h
1 parent 8b96229 commit 688140b

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

test/mp/test/foo-types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <mp/proxy-types.h>
99
#include <mp/type-context.h>
1010
#include <mp/type-decay.h>
11+
#include <mp/type-function.h>
1112
#include <mp/type-interface.h>
1213
#include <mp/type-map.h>
1314
#include <mp/type-message.h>

test/mp/test/foo.capnp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
2828
passMessage @13 (arg :FooMessage) -> (result :FooMessage);
2929
passMutable @14 (arg :FooMutable) -> (arg :FooMutable);
3030
passEnum @15 (arg :Int32) -> (result :Int32);
31+
passFn @16 (context :Proxy.Context, fn :FooFn) -> (result :Int32);
3132
}
3233

3334
interface FooCallback $Proxy.wrap("mp::test::FooCallback") {
@@ -39,6 +40,11 @@ interface ExtendedCallback extends(FooCallback) $Proxy.wrap("mp::test::ExtendedC
3940
callExtended @0 (context :Proxy.Context, arg :Int32) -> (result :Int32);
4041
}
4142

43+
interface FooFn $Proxy.wrap("ProxyCallback<std::function<int()>>") {
44+
destroy @0 (context :Proxy.Context) -> ();
45+
call @1 (context :Proxy.Context) -> (result :Int32);
46+
}
47+
4248
struct FooStruct $Proxy.wrap("mp::test::FooStruct") {
4349
name @0 :Text;
4450
setint @1 :List(Int32);

test/mp/test/foo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef MP_TEST_FOO_H
66
#define MP_TEST_FOO_H
77

8+
#include <functional>
89
#include <map>
910
#include <memory>
1011
#include <string>
@@ -75,6 +76,7 @@ class FooImplementation
7576
FooMessage passMessage(FooMessage foo) { foo.message += " call"; return foo; }
7677
void passMutable(FooMutable& foo) { foo.message += " call"; }
7778
FooEnum passEnum(FooEnum foo) { return foo; }
79+
int passFn(std::function<int()> fn) { return fn(); }
7880
std::shared_ptr<FooCallback> m_callback;
7981
};
8082

test/mp/test/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ KJ_TEST("Call FooInterface methods")
128128
foo->passMutable(mut);
129129
KJ_EXPECT(mut.message == "init build pass call return read");
130130

131+
KJ_EXPECT(foo->passFn([]{ return 10; }) == 10);
132+
131133
disconnect_client();
132134
thread.join();
133135

0 commit comments

Comments
 (0)