MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / TEST

Function TEST

crates/c-api/tests/gc.cc:6–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace wasmtime;
5
6TEST(EqRef, CopyAndMove) {
7 Config config;
8 config.wasm_gc(true);
9 Engine engine(std::move(config));
10 Store store(engine);
11
12 auto cx = store.context();
13
14 // Create an i31 eqref.
15 EqRef eq = EqRef::from_i31(cx, 42);
16 EXPECT_TRUE(eq.is_i31(cx));
17
18 // Copy constructor
19 EqRef eq2(eq);
20
21 // Move constructor
22 EqRef eq3(std::move(eq2));
23
24 // Copy assignment
25 EqRef eq4 = eq3;
26
27 // Move assignment
28 EqRef eq5 = std::move(eq4);
29
30 EXPECT_TRUE(eq.ty(cx).is_i31());
31
32 // Upcast to anyref and check value
33 AnyRef upcast = eq.to_anyref();
34 auto val = upcast.u31(cx);
35 ASSERT_TRUE(val.has_value());
36 EXPECT_EQ(*val, 42u);
37
38 EXPECT_TRUE(upcast.ty(cx).is_i31());
39}
40
41TEST(EqRef, NullEqRef) {
42 wasmtime_eqref_t raw;

Callers

nothing calls this directly

Calls 15

wasmtime_eqref_set_nullFunction · 0.85
wasmtime_eqref_is_nullFunction · 0.85
wasmtime_eqref_to_anyrefFunction · 0.85
wasmtime_anyref_is_nullFunction · 0.85
u31Method · 0.80
i31_get_uMethod · 0.80
i31_get_sMethod · 0.80
num_fieldsMethod · 0.80
StructTypeClass · 0.50
createFunction · 0.50
ValClass · 0.50
ArrayTypeClass · 0.50

Tested by

no test coverage detected