feat: add a histrical wit-bindgen
This commit is contained in:
135
__wasm/wit-bindgen-sample/wit-bindgen/tests/codegen/variants.wit
Normal file
135
__wasm/wit-bindgen-sample/wit-bindgen/tests/codegen/variants.wit
Normal file
@@ -0,0 +1,135 @@
|
||||
enum e1 {
|
||||
a,
|
||||
}
|
||||
|
||||
e1-arg: func(x: e1)
|
||||
e1-result: func() -> e1
|
||||
|
||||
union u1 {
|
||||
u32,
|
||||
float32,
|
||||
}
|
||||
|
||||
u1-arg: func(x: u1)
|
||||
u1-result: func() -> u1
|
||||
|
||||
record empty {}
|
||||
|
||||
variant v1 {
|
||||
a,
|
||||
b(u1),
|
||||
c(e1),
|
||||
d(string),
|
||||
e(empty),
|
||||
f,
|
||||
g(u32),
|
||||
}
|
||||
|
||||
v1-arg: func(x: v1)
|
||||
v1-result: func() -> v1
|
||||
|
||||
bool-arg: func(x: bool)
|
||||
bool-result: func() -> bool
|
||||
|
||||
option-arg: func(
|
||||
a: option<bool>,
|
||||
b: option<tuple<>>,
|
||||
c: option<u32>,
|
||||
d: option<e1>,
|
||||
e: option<float32>,
|
||||
f: option<u1>,
|
||||
g: option<option<bool>>,
|
||||
)
|
||||
option-result: func() -> tuple<
|
||||
option<bool>,
|
||||
option<tuple<>>,
|
||||
option<u32>,
|
||||
option<e1>,
|
||||
option<float32>,
|
||||
option<u1>,
|
||||
option<option<bool>>,
|
||||
>
|
||||
|
||||
variant casts1 {
|
||||
a(s32),
|
||||
b(float32),
|
||||
}
|
||||
|
||||
variant casts2 {
|
||||
a(float64),
|
||||
b(float32),
|
||||
}
|
||||
|
||||
variant casts3 {
|
||||
a(float64),
|
||||
b(u64),
|
||||
}
|
||||
|
||||
variant casts4 {
|
||||
a(u32),
|
||||
b(s64),
|
||||
}
|
||||
|
||||
variant casts5 {
|
||||
a(float32),
|
||||
b(s64),
|
||||
}
|
||||
|
||||
variant casts6 {
|
||||
a(tuple<float32, u32>),
|
||||
b(tuple<u32, u32>),
|
||||
}
|
||||
|
||||
casts: func(
|
||||
a: casts1,
|
||||
b: casts2,
|
||||
c: casts3,
|
||||
d: casts4,
|
||||
e: casts5,
|
||||
f: casts6,
|
||||
) -> tuple<
|
||||
casts1,
|
||||
casts2,
|
||||
casts3,
|
||||
casts4,
|
||||
casts5,
|
||||
casts6,
|
||||
>
|
||||
|
||||
expected-arg: func(
|
||||
a: expected<unit, unit>,
|
||||
b: expected<unit, e1>,
|
||||
c: expected<e1, unit>,
|
||||
d: expected<tuple<>, tuple<>>,
|
||||
e: expected<u32, v1>,
|
||||
f: expected<string, list<u8>>,
|
||||
)
|
||||
expected-result: func() -> tuple<
|
||||
expected<unit, unit>,
|
||||
expected<unit, e1>,
|
||||
expected<e1, unit>,
|
||||
expected<tuple<>, tuple<>>,
|
||||
expected<u32, v1>,
|
||||
expected<string, list<u8>>,
|
||||
>
|
||||
|
||||
enum my-errno {
|
||||
bad1,
|
||||
bad2,
|
||||
}
|
||||
|
||||
return-expected-sugar: func() -> expected<s32, my-errno>
|
||||
return-expected-sugar2: func() -> expected<unit, my-errno>
|
||||
return-expected-sugar3: func() -> expected<my-errno, my-errno>
|
||||
return-expected-sugar4: func() -> expected<tuple<s32, u32>, my-errno>
|
||||
return-option-sugar: func() -> option<s32>
|
||||
return-option-sugar2: func() -> option<my-errno>
|
||||
|
||||
expected-simple: func() -> expected<u32, s32>
|
||||
|
||||
record is-clone {
|
||||
v1: v1,
|
||||
}
|
||||
|
||||
is-clone-arg: func(a: is-clone)
|
||||
is-clone-return: func() -> is-clone
|
||||
Reference in New Issue
Block a user