MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / Run

Function Run

tests/runtime/resources/runner.go:8–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6)
7
8func Run() {
9 {
10 val := test.TestImports()
11 val.Ok()
12 }
13
14 x := test.MakeX(5)
15 defer x.Drop()
16 assertEqual(x.GetA(), 5)
17 x.SetA(10)
18 assertEqual(x.GetA(), 10)
19
20 z1 := test.MakeZ(10)
21 defer z1.Drop()
22 assertEqual(z1.GetA(), 10)
23
24 z2 := test.MakeZ(20)
25 defer z2.Drop()
26 assertEqual(z2.GetA(), 20)
27
28 xadd := test.XAdd(x, 5)
29 defer xadd.Drop()
30 assertEqual(xadd.GetA(), 15)
31
32 zadd := test.Add(z1, z2)
33 defer zadd.Drop()
34 assertEqual(zadd.GetA(), 30)
35
36 droppedZsStart := test.ZNumDropped()
37
38 z1.Drop()
39 z2.Drop()
40
41 test.Consume(xadd)
42
43 droppedZsEnd := test.ZNumDropped()
44
45 assertEqual(droppedZsEnd, droppedZsStart+2)
46}
47
48func assertEqual[T comparable](a T, b T) {
49 if a != b {

Callers

nothing calls this directly

Calls 6

assertEqualFunction · 0.70
TestImportsMethod · 0.45
GetAMethod · 0.45
SetAMethod · 0.45
AddMethod · 0.45
ConsumeMethod · 0.45

Tested by

no test coverage detected