Skip to content

Commit 0b2a3af

Browse files
authored
Fix nodiscard warnings in C++ tests (#13148)
Fixes warnings that cropped up when `gc` was changed to return a result.
1 parent cc84f98 commit 0b2a3af

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

crates/c-api/tests/func.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ TEST(TypedFunc, Call) {
8787
FuncType ty({ValKind::ExternRef, ValKind::ExternRef},
8888
{ValKind::ExternRef, ValKind::ExternRef});
8989
Func f(store, ty, [](auto caller, auto params, auto results) {
90-
caller.context().gc();
90+
caller.context().gc().unwrap();
9191
EXPECT_TRUE(params[0].externref());
9292
EXPECT_EQ(std::any_cast<int>(params[0].externref()->data(caller)), 100);
9393
EXPECT_FALSE(params[1].externref());
9494
results[0] = ExternRef(caller, int(3));
9595
results[1] = std::optional<ExternRef>(std::nullopt);
96-
caller.context().gc();
96+
caller.context().gc().unwrap();
9797
return std::monostate();
9898
});
9999

@@ -102,7 +102,7 @@ TEST(TypedFunc, Call) {
102102
auto func = f.typed<ExternRefPair, ExternRefPair>(store).unwrap();
103103
auto result =
104104
func.call(store, {ExternRef(store, int(100)), std::nullopt}).unwrap();
105-
store.context().gc();
105+
store.context().gc().unwrap();
106106
EXPECT_EQ(std::any_cast<int>(std::get<0>(result)->data(store)), 3);
107107
EXPECT_EQ(std::get<1>(result), std::nullopt);
108108
}

crates/c-api/tests/store.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TEST(Store, Smoke) {
2525

2626
store = Store(engine);
2727
store.limiter(-1, -1, -1, -1, -1);
28-
store.context().gc();
28+
store.context().gc().unwrap();
2929
store.context().get_fuel().err();
3030
store.context().set_fuel(1).err();
3131
store.context().set_epoch_deadline(1);

crates/c-api/tests/val.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ TEST(Val, DropsExternRef) {
110110
flag = guard.flag();
111111
ExternRef r(store, std::make_shared<SetOnDrop>(std::move(guard)));
112112
EXPECT_FALSE(flag->load());
113-
store.gc();
113+
store.gc().unwrap();
114114
EXPECT_FALSE(flag->load());
115115
}
116116
EXPECT_FALSE(flag->load());
117-
store.gc();
117+
store.gc().unwrap();
118118
EXPECT_TRUE(flag->load());
119119

120120
// Test that if a `Val(ExternRef)` is created and dropped it doesn't leak.
@@ -124,11 +124,11 @@ TEST(Val, DropsExternRef) {
124124
ExternRef r(store, std::make_shared<SetOnDrop>(std::move(guard)));
125125
Val v(r);
126126
EXPECT_FALSE(flag->load());
127-
store.gc();
127+
store.gc().unwrap();
128128
EXPECT_FALSE(flag->load());
129129
}
130130
EXPECT_FALSE(flag->load());
131-
store.gc();
131+
store.gc().unwrap();
132132
EXPECT_TRUE(flag->load());
133133

134134
// Similar to above testing a variety of APIs.
@@ -147,10 +147,10 @@ TEST(Val, DropsExternRef) {
147147
v3 = v2;
148148
v = std::move(v2);
149149

150-
store.gc();
150+
store.gc().unwrap();
151151
EXPECT_FALSE(flag->load());
152152
}
153153
EXPECT_FALSE(flag->load());
154-
store.gc();
154+
store.gc().unwrap();
155155
EXPECT_TRUE(flag->load());
156156
}

0 commit comments

Comments
 (0)