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