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

Function TEST

crates/c-api/tests/global.cc:8–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace wasmtime;
7
8TEST(Global, Smoke) {
9 Engine engine;
10 Store store(engine);
11 Global::create(store, GlobalType(ValType::i32(), true), 3.0).err();
12 Global::create(store, GlobalType(ValType::i32(), true), 3).unwrap();
13 Global::create(store, GlobalType(ValType::i32(), false), 3).unwrap();
14
15 Global g =
16 Global::create(store, GlobalType(ValType::i32(), true), 4).unwrap();
17 EXPECT_EQ(g.get(store).i32(), 4);
18 g.set(store, 10).unwrap();
19 EXPECT_EQ(g.get(store).i32(), 10);
20 g.set(store, 10.23).err();
21 EXPECT_EQ(g.get(store).i32(), 10);
22
23 EXPECT_EQ(g.type(store)->content(), ValType::i32());
24 EXPECT_TRUE(g.type(store)->is_mutable());
25}

Callers

nothing calls this directly

Calls 10

createFunction · 0.50
GlobalTypeClass · 0.50
errMethod · 0.45
unwrapMethod · 0.45
i32Method · 0.45
getMethod · 0.45
setMethod · 0.45
contentMethod · 0.45
typeMethod · 0.45
is_mutableMethod · 0.45

Tested by

no test coverage detected