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

Function Run

tests/runtime/variants/runner.go:10–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func Run() {
11 assertEqual(test.RoundtripOption(Some[float32](1.0)).Some(), 1)
12 assertEqual(test.RoundtripOption(None[float32]()).Tag(), OptionNone)
13 assertEqual(test.RoundtripOption(Some[float32](2.0)).Some(), 2)
14
15 assertEqual(test.RoundtripResult(Ok[uint32, float32](2)).Ok(), 2.0)
16 assertEqual(test.RoundtripResult(Ok[uint32, float32](4)).Ok(), 4.0)
17 assertEqual(test.RoundtripResult(Err[uint32, float32](5.3)).Err(), 5)
18
19 assertEqual(test.InvertBool(true), false)
20 assertEqual(test.InvertBool(false), true)
21
22 {
23 a, b, c, d, e, f := test.VariantCasts(test.Casts{
24 test.MakeC1A(1),
25 test.MakeC2A(2),
26 test.MakeC3A(3),
27 test.MakeC4A(4),
28 test.MakeC5A(5),
29 test.MakeC6A(6.0),
30 })
31 assertEqual(a.A(), 1)
32 assertEqual(b.A(), 2)
33 assertEqual(c.A(), 3)
34 assertEqual(d.A(), 4)
35 assertEqual(e.A(), 5)
36 assertEqual(f.A(), 6.0)
37 }
38
39 {
40 a, b, c, d, e, f := test.VariantCasts(test.Casts{
41 test.MakeC1B(1),
42 test.MakeC2B(2.0),
43 test.MakeC3B(3.0),
44 test.MakeC4B(4.0),
45 test.MakeC5B(5.0),
46 test.MakeC6B(6.0),
47 })
48 assertEqual(a.B(), 1)
49 assertEqual(b.B(), 2.0)
50 assertEqual(c.B(), 3.0)
51 assertEqual(d.B(), 4.0)
52 assertEqual(e.B(), 5.0)
53 assertEqual(f.B(), 6.0)
54 }
55
56 {
57 a, b, c, d := test.VariantZeros(test.Zeros{
58 test.MakeZ1A(1),
59 test.MakeZ2A(2),
60 test.MakeZ3A(3.0),
61 test.MakeZ4A(4.0),
62 })
63 assertEqual(a.A(), 1)
64 assertEqual(b.A(), 2)
65 assertEqual(c.A(), 3.0)
66 assertEqual(d.A(), 4.0)
67 }

Callers

nothing calls this directly

Calls 10

BMethod · 0.80
assertEqualFunction · 0.70
RoundtripOptionMethod · 0.45
RoundtripResultMethod · 0.45
InvertBoolMethod · 0.45
VariantCastsMethod · 0.45
AMethod · 0.45
VariantZerosMethod · 0.45
VariantTypedefsMethod · 0.45
VariantEnumsMethod · 0.45

Tested by

no test coverage detected