package test:pkg;
type a = u8;
type b = s8;
type c = u16;
type d = s16;
type e = u32;
type f = s32;
type g = u64;
type h = s64;
type i = f32;
type j = f64;
type k = bool;
type l = char;
type m = string;
record n {
a: list<u8>,
b: tuple<s8, u16, s16>,
c: option<u32>,
}
variant o {
foo,
bar(n),
baz(tuple<n, n, n>),
}
flags p {
foo,
bar,
baz,
}
enum q {
a,
b,
c,
}
interface r {
type a = string;
type b = u16;
type c = b;
resource d {
constructor(a: a);
a: func(b: b);
b: static func(c: c);
}
f: func(a: a, b: b, c: c, d: d) -> tuple<c, b, d, a>;
}
interface s {
use r.{a, b, c};
record n {
a: list<u8>,
b: tuple<s8, u16, s16>,
c: option<u32>,
}
variant o {
foo,
bar(n),
baz(tuple<n, n, n>),
}
flags p {
foo,
bar,
baz,
}
f: func(a: a, b: b, c: c) -> tuple<c, b, a>;
}
world t {
use r.{a, b, c};
import f: func(a: a, b: b, c: c) -> tuple<c, b, a>;
record n {
a: list<u8>,
b: tuple<s8, u16, s16>,
c: option<u32>,
}
variant o {
foo,
bar(n),
baz(tuple<n, n, n>),
}
flags p {
foo,
bar,
baz,
}
export f: func(a: a, b: b, c: c) -> tuple<n, o, p>;
}
// Test encoding of aliases
type a2 = a;
type b2 = b;
type c2 = c;
type d2 = d;
type e2 = e;
type f2 = f;
type g2 = g;
type h2 = h;
type i2 = i;
type j2 = j;
type k2 = k;
type l2 = l;
type n2 = n;
type m2 = m;
type o2 = o;
type p2 = p;
type q2 = q;
// Test encoding of aliases to inline-created defined types
type list-alias = list<u8>;
type option-alias = option<string>;
type result-alias = result<u32, string>;
type tuple-alias = tuple<u8, u16>;
type nested-list-alias = list<list<u8>>;
// wasip3 types: stream, future, error-context
type stream1 = stream;
type stream2 = stream<u8>;
type stream3 = stream<list<string>>;
type future1 = future;
type future2 = future<u32>;
type future3 = future<option<string>>;
type ec = error-context;
// async function types
type async-fn1 = async func() -> string;
type async-fn2 = async func(data: list<u8>) -> stream<u8>;
type sync-fn = func() -> string;
// interface with async functions and wasip3 types
interface async-iface {
process: async func(input: list<u8>) -> stream<u8>;
get-result: async func() -> future<string>;
sync-op: func(x: u32) -> u32;
type my-stream = stream<u32>;
type my-future = future<string>;
type my-ec = error-context;
}
// world with async imports/exports
world async-world {
import run: async func() -> string;
import fetch: async func(url: string) -> stream<u8>;
export process: async func(data: list<u8>) -> future<u32>;
}