From d9cd64f47f01d74df17cc705d1e6088f6c713af6 Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Fri, 26 May 2023 14:43:21 -0700 Subject: [PATCH 1/2] update go generator to re-enable codegen-tests Signed-off-by: Jiaxiao Zhou (Mossaka) --- Cargo.toml | 2 +- crates/go/src/lib.rs | 288 +++++++++++++++++++++---------------- crates/go/tests/codegen.rs | 3 - 3 files changed, 168 insertions(+), 125 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 67a9cbb49..aea7bda17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ default = [ 'rust', 'markdown', 'teavm-java', - # 'go', + 'go', ] c = ['dep:wit-bindgen-c'] rust = ['dep:wit-bindgen-rust'] diff --git a/crates/go/src/lib.rs b/crates/go/src/lib.rs index 2131a0a71..0d773c5ea 100644 --- a/crates/go/src/lib.rs +++ b/crates/go/src/lib.rs @@ -68,17 +68,21 @@ impl Opts { pub struct TinyGo { _opts: Opts, src: Source, - export_funcs: Vec<(String, String)>, world: String, needs_result_option: bool, needs_import_unsafe: bool, needs_fmt_import: bool, sizes: SizeAlign, - interface_names: HashMap, + interface_names: HashMap, } impl TinyGo { - fn interface<'a>(&'a mut self, resolve: &'a Resolve, name: &'a str) -> InterfaceGenerator<'a> { + fn interface<'a>( + &'a mut self, + resolve: &'a Resolve, + name: &'a Option<&'a WorldKey>, + in_import: bool, + ) -> InterfaceGenerator<'a> { InterfaceGenerator { src: Source::default(), gen: self, @@ -86,12 +90,10 @@ impl TinyGo { interface: None, name, public_anonymous_types: BTreeSet::new(), + in_import, + export_funcs: Vec::new(), } } - - fn clean_up_export_funcs(&mut self) { - self.export_funcs = vec![]; - } } impl WorldGenerator for TinyGo { @@ -108,12 +110,13 @@ impl WorldGenerator for TinyGo { id: InterfaceId, _files: &mut Files, ) { - // TODO: this is not a correct way to use `name` - let name = &resolve.name_world_key(name); - self.interface_names.insert(id, name.to_string()); - self.src.push_str(&format!("// {name}\n")); + let name_raw = &resolve.name_world_key(name); + self.src + .push_str(&format!("// Import functions from {name_raw}\n")); + self.interface_names.insert(id, name.clone()); - let mut gen = self.interface(resolve, name); + let binding = Some(name); + let mut gen = self.interface(resolve, &binding, true); gen.interface = Some(id); gen.types(id); @@ -134,9 +137,10 @@ impl WorldGenerator for TinyGo { _files: &mut Files, ) { let name = &resolve.worlds[world].name; - self.src.push_str(&format!("// {name}\n")); + self.src + .push_str(&format!("// Import functions from {name}\n")); - let mut gen = self.interface(resolve, name); + let mut gen = self.interface(resolve, &None, true); for (_name, func) in funcs.iter() { gen.import(resolve, func); } @@ -153,13 +157,13 @@ impl WorldGenerator for TinyGo { id: InterfaceId, _files: &mut Files, ) { - // TODO: this is not a correct way to use `name` - let name = &resolve.name_world_key(name); - self.interface_names.insert(id, name.to_string()); - self.src.push_str(&format!("// {name}\n")); - self.clean_up_export_funcs(); + self.interface_names.insert(id, name.clone()); + let name_raw = &resolve.name_world_key(name); + self.src + .push_str(&format!("// Export functions from {name_raw}\n")); - let mut gen = self.interface(resolve, name); + let binding = Some(name); + let mut gen = self.interface(resolve, &binding, false); gen.interface = Some(id); gen.types(id); @@ -171,31 +175,6 @@ impl WorldGenerator for TinyGo { let src = mem::take(&mut gen.src); self.src.push_str(&src); - - if !self.export_funcs.is_empty() { - let interface_var_name = &name.to_snake_case(); - let interface_name = &name.to_upper_camel_case(); - - self.src - .push_str(format!("var {interface_var_name} {interface_name} = nil\n").as_str()); - self.src.push_str( - format!( - "func Set{interface_name}(i {interface_name}) {{\n {interface_var_name} = i\n}}\n" - ) - .as_str(), - ); - self.src - .push_str(format!("type {interface_name} interface {{\n").as_str()); - for (interface_func_declaration, _) in &self.export_funcs { - self.src - .push_str(format!("{interface_func_declaration}\n").as_str()); - } - self.src.push_str("}\n"); - - for (_, export_func) in &self.export_funcs { - self.src.push_str(export_func); - } - } } fn export_funcs( @@ -206,10 +185,10 @@ impl WorldGenerator for TinyGo { _files: &mut Files, ) { let name = &resolve.worlds[world].name; - self.src.push_str(&format!("// {name}\n")); - self.clean_up_export_funcs(); + self.src + .push_str(&format!("// Export functions from {name}\n")); - let mut gen = self.interface(resolve, name); + let mut gen = self.interface(resolve, &None, false); for (_name, func) in funcs.iter() { gen.export(resolve, func); } @@ -218,42 +197,16 @@ impl WorldGenerator for TinyGo { let src = mem::take(&mut gen.src); self.src.push_str(&src); - - if !self.export_funcs.is_empty() { - let interface_var_name = &name.to_snake_case(); - let interface_name = &name.to_upper_camel_case(); - - self.src - .push_str(format!("var {interface_var_name} {interface_name} = nil\n").as_str()); - self.src.push_str( - format!( - "func Set{interface_name}(i {interface_name}) {{\n {interface_var_name} = i\n}}\n" - ) - .as_str(), - ); - self.src - .push_str(format!("type {interface_name} interface {{\n").as_str()); - for (interface_func_declaration, _) in &self.export_funcs { - self.src - .push_str(format!("{interface_func_declaration}\n").as_str()); - } - self.src.push_str("}\n"); - - for (_, export_func) in &self.export_funcs { - self.src.push_str(export_func); - } - } } fn export_types( &mut self, resolve: &Resolve, - world: WorldId, + _world: WorldId, types: &[(&str, TypeId)], _files: &mut Files, ) { - let name = &resolve.worlds[world].name; - let mut gen = self.interface(resolve, name); + let mut gen = self.interface(resolve, &None, false); for (name, id) in types { gen.define_type(name, *id); } @@ -422,21 +375,81 @@ struct InterfaceGenerator<'a> { gen: &'a mut TinyGo, resolve: &'a Resolve, interface: Option, - name: &'a str, + name: &'a Option<&'a WorldKey>, public_anonymous_types: BTreeSet, + in_import: bool, + export_funcs: Vec<(String, String)>, } impl InterfaceGenerator<'_> { - fn get_typedef_target(&self, name: &str) -> String { - format!( - "{}{}", - self.name.to_upper_camel_case(), - name.to_upper_camel_case() - ) + fn get_func_or_type_name(&self, name: &str) -> String { + format!("{}{}", self.get_package_name(), name.to_upper_camel_case()) + } + + fn get_c_func_name(&self, func_name: &str) -> String { + let mut name = String::new(); + match self.name { + Some(WorldKey::Name(k)) => name.push_str(&k.to_snake_case()), + Some(WorldKey::Interface(id)) => { + if !self.in_import { + name.push_str("exports_"); + } + let iface = &self.resolve.interfaces[*id]; + let pkg = &self.resolve.packages[iface.package.unwrap()]; + name.push_str(&pkg.name.namespace.to_snake_case()); + name.push('_'); + name.push_str(&pkg.name.name.to_snake_case()); + name.push('_'); + name.push_str(&iface.name.as_ref().unwrap().to_snake_case()); + } + None => name.push_str(&self.gen.world.to_snake_case()), + } + name.push('_'); + name.push_str(&func_name.to_snake_case()); + name + } + + fn get_package_name(&self) -> String { + match self.name { + Some(key) => self.get_package_name_with(key), + None => self.gen.world.to_upper_camel_case(), + } + } + + fn get_package_name_with(&self, key: &WorldKey) -> String { + let mut name = String::new(); + match key { + WorldKey::Name(k) => name.push_str(&k.to_upper_camel_case()), + WorldKey::Interface(id) => { + if !self.in_import { + name.push_str("Exports"); + } + let iface = &self.resolve.interfaces[*id]; + let pkg = &self.resolve.packages[iface.package.unwrap()]; + name.push_str(&pkg.name.namespace.to_upper_camel_case()); + name.push_str(&pkg.name.name.to_upper_camel_case()); + name.push_str(&iface.name.as_ref().unwrap().to_upper_camel_case()); + } + } + name } - fn get_c_typedef_target(&self, name: &str) -> String { - format!("{}_{}", self.name.to_snake_case(), name.to_snake_case()) + fn get_interface_var_name(&self) -> String { + let mut name = String::new(); + match self.name { + Some(WorldKey::Name(k)) => name.push_str(&k.to_snake_case()), + Some(WorldKey::Interface(id)) => { + let iface = &self.resolve.interfaces[*id]; + let pkg = &self.resolve.packages[iface.package.unwrap()]; + name.push_str(&pkg.name.namespace.to_snake_case()); + name.push('_'); + name.push_str(&pkg.name.name.to_snake_case()); + name.push('_'); + name.push_str(&iface.name.as_ref().unwrap().to_snake_case()); + } + None => name.push_str(&self.gen.world.to_snake_case()), + } + name } fn get_ty(&mut self, ty: &Type) -> String { @@ -476,16 +489,17 @@ impl InterfaceGenerator<'_> { _ => { if let Some(name) = &ty.name { let iface = if let TypeOwner::Interface(owner) = ty.owner { - self.gen.interface_names[&owner].to_upper_camel_case() + let key = &self.gen.interface_names[&owner]; + self.get_package_name_with(key) } else { - self.name.to_upper_camel_case() + self.get_package_name() }; format!("{iface}{name}", name = name.to_upper_camel_case()) } else { self.public_anonymous_types.insert(*id); format!( "{namespace}{name}", - namespace = self.name.to_upper_camel_case(), + namespace = self.get_package_name(), name = self.get_ty_name(&Type::Id(*id)), ) } @@ -520,17 +534,25 @@ impl InterfaceGenerator<'_> { match &ty.name { Some(name) => match ty.owner { TypeOwner::Interface(owner) => { - format!( - "{namespace}_{name}_t", - namespace = self.resolve.interfaces[owner] - .name - .as_ref() - .map(|s| s.to_snake_case()) - .unwrap_or_else( - || self.gen.interface_names[&owner].to_snake_case() - ), - name = name.to_snake_case(), - ) + let key = &self.gen.interface_names[&owner]; + let mut ns = match &key { + WorldKey::Name(name) => name.to_snake_case(), + WorldKey::Interface(id) => { + let mut ns = String::new(); + let iface = &self.resolve.interfaces[*id]; + let pkg = &self.resolve.packages[iface.package.unwrap()]; + ns.push_str(&pkg.name.namespace.to_snake_case()); + ns.push('_'); + ns.push_str(&pkg.name.name.to_snake_case()); + ns.push('_'); + ns.push_str(&iface.name.as_ref().unwrap().to_snake_case()); + ns + } + }; + ns.push('_'); + ns.push_str(name.to_snake_case().as_str()); + ns.push_str("_t"); + ns } TypeOwner::World(owner) => { format!( @@ -588,7 +610,8 @@ impl InterfaceGenerator<'_> { self.resolve.worlds[owner].name.to_upper_camel_case() } TypeOwner::Interface(owner) => { - self.gen.interface_names[&owner].to_upper_camel_case() + let key = &self.gen.interface_names[&owner]; + self.get_package_name_with(key) } TypeOwner::None => "".into(), }; @@ -896,10 +919,10 @@ impl InterfaceGenerator<'_> { in_import: bool, ) -> String { let mut src = Source::default(); - let name = if in_import { - self.get_c_typedef_target(&func.name) + let func_name = if in_import { + self.get_c_func_name(&func.name) } else { - self.get_typedef_target(&func.name) + self.get_func_or_type_name(&func.name) }; if !in_import { @@ -907,7 +930,7 @@ impl InterfaceGenerator<'_> { } else { src.push_str("C."); } - src.push_str(&name); + src.push_str(&func_name); src.push_str("("); // prepare args @@ -936,7 +959,7 @@ impl InterfaceGenerator<'_> { fn print_func_signature(&mut self, resolve: &Resolve, func: &Function) { self.src.push_str("func "); - let func_name = self.name.to_upper_camel_case(); + let func_name = self.get_package_name(); self.src.push_str(&func_name); let func_sig = self.get_func_signature_no_interface(resolve, func); self.src.push_str(&func_sig); @@ -995,7 +1018,7 @@ impl InterfaceGenerator<'_> { TypeDefKind::Tuple(t) => { let name = format!( "{}{}", - self.name.to_upper_camel_case(), + self.get_package_name(), self.get_ty_name(&Type::Id(ty)) ); self.src.push_str(&format!("type {name} struct {{\n",)); @@ -1194,7 +1217,7 @@ impl InterfaceGenerator<'_> { let mut src = String::new(); // header src.push_str("//export "); - let name = self.get_c_typedef_target(&func.name); + let name = self.get_c_func_name(&func.name); src.push_str(&name); src.push('\n'); @@ -1204,8 +1227,8 @@ impl InterfaceGenerator<'_> { // free all the parameters for (name, ty) in func.params.iter() { - if owns_anything(resolve, &ty) { - let free = self.get_free_c_arg(&ty, &avoid_keyword(&name.to_snake_case())); + if owns_anything(resolve, ty) { + let free = self.get_free_c_arg(ty, &avoid_keyword(&name.to_snake_case())); src.push_str(&free); } } @@ -1217,7 +1240,7 @@ impl InterfaceGenerator<'_> { // invoke let invoke = format!( "{}.{}({})", - &self.name.to_snake_case(), + &self.get_interface_var_name(), &func.name.to_upper_camel_case(), args.iter() .enumerate() @@ -1268,15 +1291,38 @@ impl InterfaceGenerator<'_> { src.push_str("\n}\n"); src }; - self.gen - .export_funcs - .push((interface_method_decl, export_func)); + self.export_funcs.push((interface_method_decl, export_func)); } fn finish(&mut self) { while let Some(ty) = self.public_anonymous_types.pop_last() { self.print_anonymous_type(ty); } + + if !self.in_import && !self.export_funcs.is_empty() { + let interface_var_name = &self.get_interface_var_name(); + let interface_name = &self.get_package_name(); + + self.src + .push_str(format!("var {interface_var_name} {interface_name} = nil\n").as_str()); + self.src.push_str( + format!( + "func Set{interface_name}(i {interface_name}) {{\n {interface_var_name} = i\n}}\n" + ) + .as_str(), + ); + self.src + .push_str(format!("type {interface_name} interface {{\n").as_str()); + for (interface_func_declaration, _) in &self.export_funcs { + self.src + .push_str(format!("{interface_func_declaration}\n").as_str()); + } + self.src.push_str("}\n"); + + for (_, export_func) in &self.export_funcs { + self.src.push_str(export_func); + } + } } } @@ -1292,7 +1338,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { record: &wit_bindgen_core::wit_parser::Record, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); self.src.push_str(&format!("type {name} struct {{\n",)); for field in record.fields.iter() { let ty = self.get_ty(&field.ty); @@ -1309,7 +1355,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { flags: &wit_bindgen_core::wit_parser::Flags, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); // TODO: use flags repr to determine how many flags are needed self.src.push_str(&format!("type {name} uint64\n")); self.src.push_str("const (\n"); @@ -1338,7 +1384,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { tuple: &wit_bindgen_core::wit_parser::Tuple, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); self.src.push_str(&format!("type {name} struct {{\n",)); for (i, case) in tuple.types.iter().enumerate() { let ty = self.get_ty(case); @@ -1354,7 +1400,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { variant: &wit_bindgen_core::wit_parser::Variant, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); // TODO: use variant's tag to determine how many cases are needed // this will help to optmize the Kind type. self.src.push_str(&format!("type {name}Kind int\n\n")); @@ -1411,7 +1457,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { union: &wit_bindgen_core::wit_parser::Union, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); // TODO: use variant's tag to determine how many cases are needed // this will help to optmize the Kind type. self.src.push_str(&format!("type {name}Kind int\n\n")); @@ -1445,7 +1491,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { enum_: &wit_bindgen_core::wit_parser::Enum, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); // TODO: use variant's tag to determine how many cases are needed // this will help to optmize the Kind type. self.src.push_str(&format!("type {name}Kind int\n\n")); @@ -1476,7 +1522,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { ty: &wit_bindgen_core::wit_parser::Type, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); let ty = self.get_ty(ty); self.src.push_str(&format!("type {name} = {ty}\n")); } @@ -1488,7 +1534,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { ty: &wit_bindgen_core::wit_parser::Type, _docs: &wit_bindgen_core::wit_parser::Docs, ) { - let name = self.get_typedef_target(name); + let name = self.get_func_or_type_name(name); let ty = self.get_ty(ty); self.src.push_str(&format!("type {name} = {ty}\n")); } diff --git a/crates/go/tests/codegen.rs b/crates/go/tests/codegen.rs index 987015908..e40753721 100644 --- a/crates/go/tests/codegen.rs +++ b/crates/go/tests/codegen.rs @@ -11,9 +11,6 @@ macro_rules! codegen_test { (issue544 $name:tt $test:tt) => {}; (issue551 $name:tt $test:tt) => {}; - // TODO: should fix handling of new `WorldKey` in go generator - ($id:ident $name:tt $test:tt) => {}; - ($id:ident $name:tt $test:tt) => { #[test] fn $id() { From f74ba82e8a1c10ad23cc5f7e06c6781f29b62f8a Mon Sep 17 00:00:00 2001 From: "Jiaxiao Zhou (Mossaka)" Date: Fri, 26 May 2023 15:40:58 -0700 Subject: [PATCH 2/2] Re-enable runtime tests Signed-off-by: Jiaxiao Zhou (Mossaka) --- tests/runtime/flavorful/wasm.go | 92 +++++----- tests/runtime/lists/wasm.go | 96 +++++----- tests/runtime/main.rs | 5 +- tests/runtime/numbers/wasm.go | 78 ++++---- tests/runtime/records/wasm.go | 72 ++++---- tests/runtime/smoke/wasm.go | 2 +- tests/runtime/unions/wasm.go | 312 ++++++++++++++++---------------- 7 files changed, 327 insertions(+), 330 deletions(-) diff --git a/tests/runtime/flavorful/wasm.go b/tests/runtime/flavorful/wasm.go index 721d0a3a4..78f289809 100644 --- a/tests/runtime/flavorful/wasm.go +++ b/tests/runtime/flavorful/wasm.go @@ -7,52 +7,52 @@ import ( func init() { n := &FlavorfulImpl{} SetFlavorful(n) - SetExports(n) + SetExportsTestFlavorfulTest(n) } type FlavorfulImpl struct{} func (f FlavorfulImpl) TestImports() { - ImportsFListInRecord1(ImportsListInRecord1{"list_in_record1"}) - if ImportsFListInRecord2().A != "list_in_record2" { - panic("ImportsFListInRecord2") + TestFlavorfulTestFListInRecord1(TestFlavorfulTestListInRecord1{"list_in_record1"}) + if TestFlavorfulTestFListInRecord2().A != "list_in_record2" { + panic("TestFlavorfulTestFListInRecord2") } - if ImportsFListInRecord3(ImportsListInRecord3{"list_in_record3 input"}).A != "list_in_record3 output" { - panic("ImportsFListInRecord3") + if TestFlavorfulTestFListInRecord3(TestFlavorfulTestListInRecord3{"list_in_record3 input"}).A != "list_in_record3 output" { + panic("TestFlavorfulTestFListInRecord3") } - if ImportsFListInRecord4(ImportsListInAlias{"input4"}).A != "result4" { - panic("ImportsFListInRecord4") + if TestFlavorfulTestFListInRecord4(TestFlavorfulTestListInAlias{"input4"}).A != "result4" { + panic("TestFlavorfulTestFListInRecord4") } var b Result[struct{}, string] b.SetErr("bar") - ImportsFListInVariant1(Some[string]("foo"), b, ImportsListInVariant1V3F0("baz")) - if ImportsFListInVariant2().Unwrap() != "list_in_variant2" { - panic("ImportsFListInVariant2") + TestFlavorfulTestFListInVariant1(Some[string]("foo"), b, TestFlavorfulTestListInVariant1V3F0("baz")) + if TestFlavorfulTestFListInVariant2().Unwrap() != "list_in_variant2" { + panic("TestFlavorfulTestFListInVariant2") } - if ImportsFListInVariant3(Some[string]("input3")).Unwrap() != "output3" { - panic("ImportsFListInVariant3") + if TestFlavorfulTestFListInVariant3(Some[string]("input3")).Unwrap() != "output3" { + panic("TestFlavorfulTestFListInVariant3") } - if !ImportsErrnoResult().IsErr() { - panic("ImportsErrnoResult") + if !TestFlavorfulTestErrnoResult().IsErr() { + panic("TestFlavorfulTestErrnoResult") } - ImportsMyErrnoA() + TestFlavorfulTestMyErrnoA() // TODO: be able to print my_error_a - if !ImportsErrnoResult().IsOk() { - panic("ImportsErrnoResult") + if !TestFlavorfulTestErrnoResult().IsOk() { + panic("TestFlavorfulTestErrnoResult") } - t1, t2 := ImportsListTypedefs("typedef1", []string{"typedef2"}) + t1, t2 := TestFlavorfulTestListTypedefs("typedef1", []string{"typedef2"}) if len(t1) != 8 { - panic("ImportsListTypedefs") + panic("TestFlavorfulTestListTypedefs") } if len(t2) != 1 { - panic("ImportsListTypedefs") + panic("TestFlavorfulTestListTypedefs") } if t2[0] != "typedef4" { - panic("ImportsListTypedefs") + panic("TestFlavorfulTestListTypedefs") } var v2_ok Result[struct{}, struct{}] @@ -60,57 +60,57 @@ func (f FlavorfulImpl) TestImports() { var v2_err Result[struct{}, struct{}] v2_err.SetErr(struct{}{}) - v1, v2, v3 := ImportsListOfVariants( + v1, v2, v3 := TestFlavorfulTestListOfVariants( []bool{true, false}, []Result[struct{}, struct{}]{v2_ok, v2_err}, - []ImportsMyErrno{ImportsMyErrnoSuccess(), ImportsMyErrnoA()}, + []TestFlavorfulTestMyErrno{TestFlavorfulTestMyErrnoSuccess(), TestFlavorfulTestMyErrnoA()}, ) if v1[0] != false { - panic("ImportsListOfVariants") + panic("TestFlavorfulTestListOfVariants") } if v1[1] != true { - panic("ImportsListOfVariants") + panic("TestFlavorfulTestListOfVariants") } if v2[0].IsOk() { - panic("ImportsListOfVariants") + panic("TestFlavorfulTestListOfVariants") } if v2[1].IsErr() { - panic("ImportsListOfVariants") + panic("TestFlavorfulTestListOfVariants") } - if v3[0].Kind() != ImportsMyErrnoKindA { - panic("ImportsListOfVariants") + if v3[0].Kind() != TestFlavorfulTestMyErrnoKindA { + panic("TestFlavorfulTestListOfVariants") } - if v3[1].Kind() != ImportsMyErrnoKindB { - panic("ImportsListOfVariants") + if v3[1].Kind() != TestFlavorfulTestMyErrnoKindB { + panic("TestFlavorfulTestListOfVariants") } } -func (f FlavorfulImpl) FListInRecord1(a ExportsListInRecord1) { +func (f FlavorfulImpl) FListInRecord1(a ExportsTestFlavorfulTestListInRecord1) { if a.A != "list_in_record1" { panic("FListInRecord1") } } -func (f FlavorfulImpl) FListInRecord2() ExportsListInRecord2 { - return ExportsListInRecord2{"list_in_record2"} +func (f FlavorfulImpl) FListInRecord2() ExportsTestFlavorfulTestListInRecord2 { + return ExportsTestFlavorfulTestListInRecord2{"list_in_record2"} } -func (f FlavorfulImpl) FListInRecord3(a ExportsListInRecord3) ExportsListInRecord3 { +func (f FlavorfulImpl) FListInRecord3(a ExportsTestFlavorfulTestListInRecord3) ExportsTestFlavorfulTestListInRecord3 { if a.A != "list_in_record3 input" { panic("FListInRecord3") } - return ExportsListInRecord3{"list_in_record3 output"} + return ExportsTestFlavorfulTestListInRecord3{"list_in_record3 output"} } -func (f FlavorfulImpl) FListInRecord4(a ExportsListInRecord4) ExportsListInRecord4 { +func (f FlavorfulImpl) FListInRecord4(a ExportsTestFlavorfulTestListInRecord4) ExportsTestFlavorfulTestListInRecord4 { if a.A != "input4" { panic("FListInRecord4") } - return ExportsListInRecord4{"result4"} + return ExportsTestFlavorfulTestListInRecord4{"result4"} } -func (f FlavorfulImpl) FListInVariant1(a Option[string], b Result[struct{}, string], c ExportsListInVariant1V3) { +func (f FlavorfulImpl) FListInVariant1(a Option[string], b Result[struct{}, string], c ExportsTestFlavorfulTestListInVariant1V3) { if a.Unwrap() != "foo" { panic("FListInVariant1") } @@ -118,11 +118,11 @@ func (f FlavorfulImpl) FListInVariant1(a Option[string], b Result[struct{}, stri panic("FListInVariant1") } switch c.Kind() { - case ExportsListInVariant1V3KindF0: + case ExportsTestFlavorfulTestListInVariant1V3KindF0: if c.GetF0() != "baz" { panic("FListInVariant1") } - case ExportsListInVariant1V3KindF1: + case ExportsTestFlavorfulTestListInVariant1V3KindF1: panic("FListInVariant1") } } @@ -138,9 +138,9 @@ func (f FlavorfulImpl) FListInVariant3(a Option[string]) Option[string] { return Some[string]("output3") } -func (f FlavorfulImpl) ErrnoResult() Result[struct{}, ExportsMyErrno] { - var res Result[struct{}, ExportsMyErrno] - res.SetErr(ExportsMyErrnoB()) +func (f FlavorfulImpl) ErrnoResult() Result[struct{}, ExportsTestFlavorfulTestMyErrno] { + var res Result[struct{}, ExportsTestFlavorfulTestMyErrno] + res.SetErr(ExportsTestFlavorfulTestMyErrnoB()) return res } @@ -157,7 +157,7 @@ func (f FlavorfulImpl) ListTypedefs(a string, c []string) ([]uint8, []string) { return []uint8("typedef3"), []string{"typedef4"} } -func (f FlavorfulImpl) ListOfVariants(a []bool, b []Result[struct{}, struct{}], c []ExportsMyErrno) ([]bool, []Result[struct{}, struct{}], []ExportsMyErrno) { +func (f FlavorfulImpl) ListOfVariants(a []bool, b []Result[struct{}, struct{}], c []ExportsTestFlavorfulTestMyErrno) ([]bool, []Result[struct{}, struct{}], []ExportsTestFlavorfulTestMyErrno) { return a, b, c } diff --git a/tests/runtime/lists/wasm.go b/tests/runtime/lists/wasm.go index 7689ef19d..4a8b53b9a 100644 --- a/tests/runtime/lists/wasm.go +++ b/tests/runtime/lists/wasm.go @@ -8,123 +8,123 @@ import ( func init() { a := ListImpl{} SetLists(a) - SetExports(a) + SetExportsTestListsTest(a) } type ListImpl struct { } func (i ListImpl) TestImports() { - ImportsEmptyListParam([]uint8{}) - ImportsEmptyStringParam("") - res := ImportsEmptyListResult() + TestListsTestEmptyListParam([]uint8{}) + TestListsTestEmptyStringParam("") + res := TestListsTestEmptyListResult() if len(res) != 0 { - panic("ImportsEmptyListResult") + panic("TestListsTestEmptyListResult") } - res2 := ImportsEmptyStringResult() + res2 := TestListsTestEmptyStringResult() if res2 != "" { - panic("ImportsEmptyStringResult") + panic("TestListsTestEmptyStringResult") } - ImportsListParam([]uint8{1, 2, 3, 4}) - ImportsListParam2("foo") - ImportsListParam3([]string{"foo", "bar", "baz"}) - ImportsListParam4([][]string{{"foo", "bar"}, {"baz"}}) - res3 := ImportsListResult() + TestListsTestListParam([]uint8{1, 2, 3, 4}) + TestListsTestListParam2("foo") + TestListsTestListParam3([]string{"foo", "bar", "baz"}) + TestListsTestListParam4([][]string{{"foo", "bar"}, {"baz"}}) + res3 := TestListsTestListResult() if len(res3) != 5 { - panic("ImportsListResult") + panic("TestListsTestListResult") } for i := range res3 { if res3[i] != uint8(i+1) { - panic("ImportsListResult") + panic("TestListsTestListResult") } } - res4 := ImportsListResult2() + res4 := TestListsTestListResult2() if res4 != "hello!" { - panic("ImportsListResult2") + panic("TestListsTestListResult2") } - res5 := ImportsListResult3() + res5 := TestListsTestListResult3() if len(res5) != 2 { - panic("ImportsListResult3") + panic("TestListsTestListResult3") } if res5[0] != "hello," { - panic("ImportsListResult3") + panic("TestListsTestListResult3") } if res5[1] != "world!" { - panic("ImportsListResult3") + panic("TestListsTestListResult3") } - res6 := ImportsListRoundtrip([]uint8{}) + res6 := TestListsTestListRoundtrip([]uint8{}) if len(res6) != 0 { - panic("ImportsListRoundtrip") + panic("TestListsTestListRoundtrip") } - res7 := ImportsListRoundtrip([]uint8{1, 2, 3, 4, 5}) + res7 := TestListsTestListRoundtrip([]uint8{1, 2, 3, 4, 5}) if len(res7) != 5 { - panic("ImportsListRoundtrip") + panic("TestListsTestListRoundtrip") } - res8 := ImportsStringRoundtrip("") + res8 := TestListsTestStringRoundtrip("") if res8 != "" { - panic("ImportsStringRoundtrip") + panic("TestListsTestStringRoundtrip") } - res9 := ImportsStringRoundtrip("hello ⚑ world") + res9 := TestListsTestStringRoundtrip("hello ⚑ world") if res9 != "hello ⚑ world" { - panic("ImportsStringRoundtrip") + panic("TestListsTestStringRoundtrip") } - u8, i8 := ImportsListMinmax8([]uint8{0, math.MaxUint8}, []int8{math.MinInt8, math.MaxInt8}) + u8, i8 := TestListsTestListMinmax8([]uint8{0, math.MaxUint8}, []int8{math.MinInt8, math.MaxInt8}) if u8[0] != uint8(0) { - panic("ImportsListMinmax8") + panic("TestListsTestListMinmax8") } if u8[1] != math.MaxUint8 { - panic("ImportsListMinmax8") + panic("TestListsTestListMinmax8") } if i8[0] != math.MinInt8 { - panic("ImportsListMinmax8") + panic("TestListsTestListMinmax8") } if i8[1] != math.MaxInt8 { - panic("ImportsListMinmax8") + panic("TestListsTestListMinmax8") } - u16, i16 := ImportsListMinmax16([]uint16{0, math.MaxUint16}, []int16{math.MinInt16, math.MaxInt16}) + u16, i16 := TestListsTestListMinmax16([]uint16{0, math.MaxUint16}, []int16{math.MinInt16, math.MaxInt16}) if u16[0] != uint16(0) { - panic("ImportsListMinmax16") + panic("TestListsTestListMinmax16") } if u16[1] != math.MaxUint16 { - panic("ImportsListMinmax16") + panic("TestListsTestListMinmax16") } if i16[0] != math.MinInt16 { - panic("ImportsListMinmax16") + panic("TestListsTestListMinmax16") } if i16[1] != math.MaxInt16 { - panic("ImportsListMinmax16") + panic("TestListsTestListMinmax16") } - u32, i32 := ImportsListMinmax32([]uint32{0, math.MaxUint32}, []int32{math.MinInt32, math.MaxInt32}) + u32, i32 := TestListsTestListMinmax32([]uint32{0, math.MaxUint32}, []int32{math.MinInt32, math.MaxInt32}) if u32[0] != uint32(0) { - panic("ImportsListMinmax32") + panic("TestListsTestListMinmax32") } if u32[1] != math.MaxUint32 { - panic("ImportsListMinmax32") + panic("TestListsTestListMinmax32") } if i32[0] != math.MinInt32 { - panic("ImportsListMinmax32") + panic("TestListsTestListMinmax32") } if i32[1] != math.MaxInt32 { - panic("ImportsListMinmax32") + panic("TestListsTestListMinmax32") } - u64, i64 := ImportsListMinmax64([]uint64{0, math.MaxUint64}, []int64{math.MinInt64, math.MaxInt64}) + u64, i64 := TestListsTestListMinmax64([]uint64{0, math.MaxUint64}, []int64{math.MinInt64, math.MaxInt64}) if u64[0] != uint64(0) { - panic("ImportsListMinmax64") + panic("TestListsTestListMinmax64") } if u64[1] != math.MaxUint64 { - panic("ImportsListMinmax64") + panic("TestListsTestListMinmax64") } if i64[0] != math.MinInt64 { - panic("ImportsListMinmax64") + panic("TestListsTestListMinmax64") } if i64[1] != math.MaxInt64 { - panic("ImportsListMinmax64") + panic("TestListsTestListMinmax64") } } diff --git a/tests/runtime/main.rs b/tests/runtime/main.rs index 36e8f09e7..8e0950929 100644 --- a/tests/runtime/main.rs +++ b/tests/runtime/main.rs @@ -211,10 +211,7 @@ fn tests(name: &str) -> Result> { } #[cfg(feature = "go")] - if !go.is_empty() - // FIXME: needs fixing after #545 - && false - { + if !go.is_empty() { let world_name = &resolve.worlds[world].name; let out_dir = out_dir.join(format!("go-{}", world_name)); drop(fs::remove_dir_all(&out_dir)); diff --git a/tests/runtime/numbers/wasm.go b/tests/runtime/numbers/wasm.go index ce3c4e687..f89c0782c 100644 --- a/tests/runtime/numbers/wasm.go +++ b/tests/runtime/numbers/wasm.go @@ -9,7 +9,7 @@ import ( func init() { n := &NumbersImpl{} SetNumbers(n) - SetExports(n) + SetExportsTestNumbersTest(n) } type NumbersImpl struct { @@ -17,126 +17,126 @@ type NumbersImpl struct { } func (i NumbersImpl) TestImports() { - if ImportsRoundtripU8(1) != 1 { + if TestNumbersTestRoundtripU8(1) != 1 { panic("roundtrip-u8") } - if ImportsRoundtripU8(0) != 0 { + if TestNumbersTestRoundtripU8(0) != 0 { panic("roundtrip-u8") } - if ImportsRoundtripU8(math.MaxUint8) != math.MaxUint8 { + if TestNumbersTestRoundtripU8(math.MaxUint8) != math.MaxUint8 { panic("roundtrip-u8") } - if ImportsRoundtripS8(1) != 1 { + if TestNumbersTestRoundtripS8(1) != 1 { panic("roundtrip-s8") } - if ImportsRoundtripS8(math.MaxInt8) != math.MaxInt8 { + if TestNumbersTestRoundtripS8(math.MaxInt8) != math.MaxInt8 { panic("roundtrip-s8") } - if ImportsRoundtripS8(math.MinInt8) != math.MinInt8 { + if TestNumbersTestRoundtripS8(math.MinInt8) != math.MinInt8 { panic("roundtrip-s8") } - if ImportsRoundtripU16(1) != 1 { + if TestNumbersTestRoundtripU16(1) != 1 { panic("roundtrip-u16") } - if ImportsRoundtripU16(0) != 0 { + if TestNumbersTestRoundtripU16(0) != 0 { panic("roundtrip-u16") } - if ImportsRoundtripU16(math.MaxUint16) != math.MaxUint16 { + if TestNumbersTestRoundtripU16(math.MaxUint16) != math.MaxUint16 { panic("roundtrip-u16") } - if ImportsRoundtripS16(1) != 1 { + if TestNumbersTestRoundtripS16(1) != 1 { panic("roundtrip-s16") } - if ImportsRoundtripS16(math.MaxInt16) != math.MaxInt16 { + if TestNumbersTestRoundtripS16(math.MaxInt16) != math.MaxInt16 { panic("roundtrip-s16") } - if ImportsRoundtripS16(math.MinInt16) != math.MinInt16 { + if TestNumbersTestRoundtripS16(math.MinInt16) != math.MinInt16 { panic("roundtrip-s16") } - if ImportsRoundtripU32(1) != 1 { + if TestNumbersTestRoundtripU32(1) != 1 { panic("roundtrip-u32") } - if ImportsRoundtripU32(0) != 0 { + if TestNumbersTestRoundtripU32(0) != 0 { panic("roundtrip-u32") } - if ImportsRoundtripU32(math.MaxUint32) != math.MaxUint32 { + if TestNumbersTestRoundtripU32(math.MaxUint32) != math.MaxUint32 { panic("roundtrip-u32") } - if ImportsRoundtripS32(1) != 1 { + if TestNumbersTestRoundtripS32(1) != 1 { panic("roundtrip-s32") } - if ImportsRoundtripS32(math.MaxInt32) != math.MaxInt32 { + if TestNumbersTestRoundtripS32(math.MaxInt32) != math.MaxInt32 { panic("roundtrip-s32") } - if ImportsRoundtripS32(math.MinInt32) != math.MinInt32 { + if TestNumbersTestRoundtripS32(math.MinInt32) != math.MinInt32 { panic("roundtrip-s32") } - if ImportsRoundtripU64(1) != 1 { + if TestNumbersTestRoundtripU64(1) != 1 { panic("roundtrip-u64") } - if ImportsRoundtripU64(0) != 0 { + if TestNumbersTestRoundtripU64(0) != 0 { panic("roundtrip-u64") } - if ImportsRoundtripU64(math.MaxUint64) != math.MaxUint64 { + if TestNumbersTestRoundtripU64(math.MaxUint64) != math.MaxUint64 { panic("roundtrip-u64") } - if ImportsRoundtripS64(1) != 1 { + if TestNumbersTestRoundtripS64(1) != 1 { panic("roundtrip-s64") } - if ImportsRoundtripS64(math.MaxInt64) != math.MaxInt64 { + if TestNumbersTestRoundtripS64(math.MaxInt64) != math.MaxInt64 { panic("roundtrip-s64") } - if ImportsRoundtripS64(math.MinInt64) != math.MinInt64 { + if TestNumbersTestRoundtripS64(math.MinInt64) != math.MinInt64 { panic("roundtrip-s64") } - if ImportsRoundtripFloat32(1.0) != 1.0 { + if TestNumbersTestRoundtripFloat32(1.0) != 1.0 { panic("roundtrip-float32") } - if ImportsRoundtripFloat32(math.MaxFloat32) != math.MaxFloat32 { + if TestNumbersTestRoundtripFloat32(math.MaxFloat32) != math.MaxFloat32 { panic("roundtrip-float32") } - if ImportsRoundtripFloat32(math.SmallestNonzeroFloat32) != math.SmallestNonzeroFloat32 { + if TestNumbersTestRoundtripFloat32(math.SmallestNonzeroFloat32) != math.SmallestNonzeroFloat32 { panic("roundtrip-float32") } - if ImportsRoundtripFloat64(1.0) != 1.0 { + if TestNumbersTestRoundtripFloat64(1.0) != 1.0 { panic("roundtrip-float64") } - if ImportsRoundtripFloat64(math.MaxFloat64) != math.MaxFloat64 { + if TestNumbersTestRoundtripFloat64(math.MaxFloat64) != math.MaxFloat64 { panic("roundtrip-float64") } - if ImportsRoundtripFloat64(math.SmallestNonzeroFloat64) != math.SmallestNonzeroFloat64 { + if TestNumbersTestRoundtripFloat64(math.SmallestNonzeroFloat64) != math.SmallestNonzeroFloat64 { panic("roundtrip-float64") } - if !math.IsNaN(ImportsRoundtripFloat64(math.NaN())) { + if !math.IsNaN(TestNumbersTestRoundtripFloat64(math.NaN())) { panic("roundtrip-float64") } - if ImportsRoundtripChar('a') != 'a' { + if TestNumbersTestRoundtripChar('a') != 'a' { panic("roundtrip-char") } - if ImportsRoundtripChar(' ') != ' ' { + if TestNumbersTestRoundtripChar(' ') != ' ' { panic("roundtrip-char") } - if ImportsRoundtripChar('🚩') != '🚩' { + if TestNumbersTestRoundtripChar('🚩') != '🚩' { panic("roundtrip-char") } - ImportsSetScalar(2) - if ImportsGetScalar() != 2 { + TestNumbersTestSetScalar(2) + if TestNumbersTestGetScalar() != 2 { panic("get-scalar") } - ImportsSetScalar(4) - if ImportsGetScalar() != 4 { + TestNumbersTestSetScalar(4) + if TestNumbersTestGetScalar() != 4 { panic("get-scalar") } } diff --git a/tests/runtime/records/wasm.go b/tests/runtime/records/wasm.go index 85cad6127..a6a5cd808 100644 --- a/tests/runtime/records/wasm.go +++ b/tests/runtime/records/wasm.go @@ -7,59 +7,59 @@ import ( func init() { n := &RecordImpl{} SetRecords(n) - SetExports(n) + SetExportsTestRecordsTest(n) } type RecordImpl struct{} func (r *RecordImpl) TestImports() { - a, b := ImportsMultipleResults() + a, b := TestRecordsTestMultipleResults() if a != 4 && b != 5 { - panic("ImportsMultipleResults") + panic("TestRecordsTestMultipleResults") } - t := ImportsSwapTuple(ImportsTuple2U8U32T{1, 2}) + t := TestRecordsTestSwapTuple(TestRecordsTestTuple2U8U32T{1, 2}) if t.F0 != 2 && t.F1 != 1 { - panic("ImportsSwapTuple") + panic("TestRecordsTestSwapTuple") } // TODO: how to handle empty flags? - if ImportsRoundtripFlags1(ImportsF1_A) != ImportsF1_A { - panic("ImportsRoundtripFlags1") + if TestRecordsTestRoundtripFlags1(TestRecordsTestF1_A) != TestRecordsTestF1_A { + panic("TestRecordsTestRoundtripFlags1") } - if ImportsRoundtripFlags1(ImportsF1_B) != ImportsF1_B { - panic("ImportsRoundtripFlags1") + if TestRecordsTestRoundtripFlags1(TestRecordsTestF1_B) != TestRecordsTestF1_B { + panic("TestRecordsTestRoundtripFlags1") } - if ImportsRoundtripFlags1(ImportsF1_A|ImportsF1_B) != ImportsF1_A|ImportsF1_B { - panic("ImportsRoundtripFlags1") + if TestRecordsTestRoundtripFlags1(TestRecordsTestF1_A|TestRecordsTestF1_B) != TestRecordsTestF1_A|TestRecordsTestF1_B { + panic("TestRecordsTestRoundtripFlags1") } - if ImportsRoundtripFlags2(ImportsF2_C) != ImportsF2_C { - panic("ImportsRoundtripFlags2") + if TestRecordsTestRoundtripFlags2(TestRecordsTestF2_C) != TestRecordsTestF2_C { + panic("TestRecordsTestRoundtripFlags2") } - if ImportsRoundtripFlags2(ImportsF2_D) != ImportsF2_D { - panic("ImportsRoundtripFlags2") + if TestRecordsTestRoundtripFlags2(TestRecordsTestF2_D) != TestRecordsTestF2_D { + panic("TestRecordsTestRoundtripFlags2") } - if ImportsRoundtripFlags2(ImportsF2_C|ImportsF2_E) != ImportsF2_C|ImportsF2_E { - panic("ImportsRoundtripFlags2") + if TestRecordsTestRoundtripFlags2(TestRecordsTestF2_C|TestRecordsTestF2_E) != TestRecordsTestF2_C|TestRecordsTestF2_E { + panic("TestRecordsTestRoundtripFlags2") } - if a, b, c, d := ImportsRoundtripFlags3(ImportsFlag8_B0, ImportsFlag16_B1, ImportsFlag32_B2, ImportsFlag64_B3); a != ImportsFlag8_B0 && b != ImportsFlag16_B1 && c != ImportsFlag32_B2 && d != ImportsFlag64_B3 { - panic("ImportsRoundtripFlags3") + if a, b, c, d := TestRecordsTestRoundtripFlags3(TestRecordsTestFlag8_B0, TestRecordsTestFlag16_B1, TestRecordsTestFlag32_B2, TestRecordsTestFlag64_B3); a != TestRecordsTestFlag8_B0 && b != TestRecordsTestFlag16_B1 && c != TestRecordsTestFlag32_B2 && d != TestRecordsTestFlag64_B3 { + panic("TestRecordsTestRoundtripFlags3") } - r1 := ImportsRoundtripRecord1(ImportsR1{8, ImportsF1_A}) - if r1.A != 8 && r1.B != ImportsF1_A { - panic("ImportsRoundtripRecord1") + r1 := TestRecordsTestRoundtripRecord1(TestRecordsTestR1{8, TestRecordsTestF1_A}) + if r1.A != 8 && r1.B != TestRecordsTestF1_A { + panic("TestRecordsTestRoundtripRecord1") } - r2 := ImportsRoundtripRecord1(ImportsR1{0, ImportsF1_A | ImportsF1_B}) - if r2.A != 0 && r2.B != ImportsF1_A|ImportsF1_B { - panic("ImportsRoundtripRecord1") + r2 := TestRecordsTestRoundtripRecord1(TestRecordsTestR1{0, TestRecordsTestF1_A | TestRecordsTestF1_B}) + if r2.A != 0 && r2.B != TestRecordsTestF1_A|TestRecordsTestF1_B { + panic("TestRecordsTestRoundtripRecord1") } - ImportsTuple0(ImportsTuple0T{}) - if ImportsTuple1(ImportsTuple1U8T{1}).F0 != 1 { - panic("ImportsTuple0") + TestRecordsTestTuple0(TestRecordsTestTuple0T{}) + if TestRecordsTestTuple1(TestRecordsTestTuple1U8T{1}).F0 != 1 { + panic("TestRecordsTestTuple0") } } @@ -67,31 +67,31 @@ func (r *RecordImpl) MultipleResults() (uint8, uint16) { return 100, 200 } -func (r *RecordImpl) SwapTuple(a ExportsTuple2U8U32T) ExportsTuple2U32U8T { - return ExportsTuple2U32U8T{a.F1, a.F0} +func (r *RecordImpl) SwapTuple(a ExportsTestRecordsTestTuple2U8U32T) ExportsTestRecordsTestTuple2U32U8T { + return ExportsTestRecordsTestTuple2U32U8T{a.F1, a.F0} } -func (r *RecordImpl) RoundtripFlags1(a ExportsF1) ExportsF1 { +func (r *RecordImpl) RoundtripFlags1(a ExportsTestRecordsTestF1) ExportsTestRecordsTestF1 { return a } -func (r *RecordImpl) RoundtripFlags2(a ExportsF2) ExportsF2 { +func (r *RecordImpl) RoundtripFlags2(a ExportsTestRecordsTestF2) ExportsTestRecordsTestF2 { return a } -func (r *RecordImpl) RoundtripFlags3(a ExportsFlag8, b ExportsFlag16, c ExportsFlag32, d ExportsFlag64) (ExportsFlag8, ExportsFlag16, ExportsFlag32, ExportsFlag64) { +func (r *RecordImpl) RoundtripFlags3(a ExportsTestRecordsTestFlag8, b ExportsTestRecordsTestFlag16, c ExportsTestRecordsTestFlag32, d ExportsTestRecordsTestFlag64) (ExportsTestRecordsTestFlag8, ExportsTestRecordsTestFlag16, ExportsTestRecordsTestFlag32, ExportsTestRecordsTestFlag64) { return a, b, c, d } -func (r *RecordImpl) RoundtripRecord1(a ExportsR1) ExportsR1 { +func (r *RecordImpl) RoundtripRecord1(a ExportsTestRecordsTestR1) ExportsTestRecordsTestR1 { return a } -func (r *RecordImpl) Tuple0(a ExportsTuple0T) ExportsTuple0T { +func (r *RecordImpl) Tuple0(a ExportsTestRecordsTestTuple0T) ExportsTestRecordsTestTuple0T { return a } -func (r *RecordImpl) Tuple1(a ExportsTuple1U8T) ExportsTuple1U8T { +func (r *RecordImpl) Tuple1(a ExportsTestRecordsTestTuple1U8T) ExportsTestRecordsTestTuple1U8T { return a } diff --git a/tests/runtime/smoke/wasm.go b/tests/runtime/smoke/wasm.go index e8c2b6674..ff3c0c316 100644 --- a/tests/runtime/smoke/wasm.go +++ b/tests/runtime/smoke/wasm.go @@ -12,7 +12,7 @@ func init() { type SmokeImpl struct{} func (s SmokeImpl) Thunk() { - ImportsThunk() + TestSmokeImportsThunk() } func main() {} diff --git a/tests/runtime/unions/wasm.go b/tests/runtime/unions/wasm.go index d67c57375..4af15222c 100644 --- a/tests/runtime/unions/wasm.go +++ b/tests/runtime/unions/wasm.go @@ -8,346 +8,346 @@ import ( func init() { n := UnionsImpl{} SetUnions(n) - SetExports(n) + SetExportsTestUnionsTest(n) } type UnionsImpl struct{} func (s UnionsImpl) TestImports() { - res1 := ImportsAddOneInteger(ImportsAllIntegersF0(false)) + res1 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF0(false)) if res1.GetF0() != true { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res2 := ImportsAddOneInteger(ImportsAllIntegersF0(true)) + res2 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF0(true)) if res2.GetF0() != false { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res3 := ImportsAddOneInteger(ImportsAllIntegersF1(0)) + res3 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF1(0)) if res3.GetF1() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res4 := ImportsAddOneInteger(ImportsAllIntegersF1(math.MaxUint8)) + res4 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF1(math.MaxUint8)) if res4.GetF1() != 0 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res5 := ImportsAddOneInteger(ImportsAllIntegersF2(0)) + res5 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF2(0)) if res5.GetF2() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res6 := ImportsAddOneInteger(ImportsAllIntegersF2(math.MaxUint16)) + res6 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF2(math.MaxUint16)) if res6.GetF2() != 0 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res7 := ImportsAddOneInteger(ImportsAllIntegersF3(0)) + res7 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF3(0)) if res7.GetF3() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res8 := ImportsAddOneInteger(ImportsAllIntegersF3(math.MaxUint32)) + res8 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF3(math.MaxUint32)) if res8.GetF3() != 0 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res9 := ImportsAddOneInteger(ImportsAllIntegersF4(0)) + res9 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF4(0)) if res9.GetF4() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res10 := ImportsAddOneInteger(ImportsAllIntegersF4(math.MaxUint64)) + res10 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF4(math.MaxUint64)) if res10.GetF4() != 0 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res11 := ImportsAddOneInteger(ImportsAllIntegersF5(0)) + res11 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF5(0)) if res11.GetF5() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res12 := ImportsAddOneInteger(ImportsAllIntegersF5(math.MaxInt8)) + res12 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF5(math.MaxInt8)) if res12.GetF5() != math.MinInt8 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res13 := ImportsAddOneInteger(ImportsAllIntegersF6(0)) + res13 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF6(0)) if res13.GetF6() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res14 := ImportsAddOneInteger(ImportsAllIntegersF6(math.MaxInt16)) + res14 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF6(math.MaxInt16)) if res14.GetF6() != math.MinInt16 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res15 := ImportsAddOneInteger(ImportsAllIntegersF7(0)) + res15 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF7(0)) if res15.GetF7() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res16 := ImportsAddOneInteger(ImportsAllIntegersF7(math.MaxInt32)) + res16 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF7(math.MaxInt32)) if res16.GetF7() != math.MinInt32 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res17 := ImportsAddOneInteger(ImportsAllIntegersF8(0)) + res17 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF8(0)) if res17.GetF8() != 1 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } - res18 := ImportsAddOneInteger(ImportsAllIntegersF8(math.MaxInt64)) + res18 := TestUnionsTestAddOneInteger(TestUnionsTestAllIntegersF8(math.MaxInt64)) if res18.GetF8() != math.MinInt64 { - panic("unexpect result in ImportsAddOneInteger") + panic("unexpect result in TestUnionsTestAddOneInteger") } // All Floats - res19 := ImportsAddOneFloat(ImportsAllFloatsF0(0.0)) + res19 := TestUnionsTestAddOneFloat(TestUnionsTestAllFloatsF0(0.0)) if res19.GetF0() != 1.0 { - panic("unexpect result in ImportsAddOneFloat") + panic("unexpect result in TestUnionsTestAddOneFloat") } - res20 := ImportsAddOneFloat(ImportsAllFloatsF1(0.0)) + res20 := TestUnionsTestAddOneFloat(TestUnionsTestAllFloatsF1(0.0)) if res20.GetF1() != 1.0 { - panic("unexpect result in ImportsAddOneFloat") + panic("unexpect result in TestUnionsTestAddOneFloat") } // All Text - if ImportsReplaceFirstChar(ImportsAllTextF0('a'), 'z').GetF0() != 'z' { - panic("unexpect result in ImportsReplaceFirstChar") + if TestUnionsTestReplaceFirstChar(TestUnionsTestAllTextF0('a'), 'z').GetF0() != 'z' { + panic("unexpect result in TestUnionsTestReplaceFirstChar") } - if ImportsReplaceFirstChar(ImportsAllTextF1("abc"), 'z').GetF1() != "zbc" { - panic("unexpect result in ImportsReplaceFirstChar") + if TestUnionsTestReplaceFirstChar(TestUnionsTestAllTextF1("abc"), 'z').GetF1() != "zbc" { + panic("unexpect result in TestUnionsTestReplaceFirstChar") } // All Integers - if ImportsIdentifyInteger(ImportsAllIntegersF0(true)) != 0 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF0(true)) != 0 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF1(0)) != 1 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF1(0)) != 1 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF2(0)) != 2 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF2(0)) != 2 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF3(0)) != 3 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF3(0)) != 3 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF4(0)) != 4 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF4(0)) != 4 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF5(0)) != 5 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF5(0)) != 5 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF6(0)) != 6 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF6(0)) != 6 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF7(0)) != 7 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF7(0)) != 7 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyInteger(ImportsAllIntegersF8(0)) != 8 { - panic("unexpect result in ImportsIdentifyInteger") + if TestUnionsTestIdentifyInteger(TestUnionsTestAllIntegersF8(0)) != 8 { + panic("unexpect result in TestUnionsTestIdentifyInteger") } - if ImportsIdentifyFloat(ImportsAllFloatsF0(0.0)) != 0 { - panic("unexpect result in ImportsIdentifyFloat") + if TestUnionsTestIdentifyFloat(TestUnionsTestAllFloatsF0(0.0)) != 0 { + panic("unexpect result in TestUnionsTestIdentifyFloat") } - if ImportsIdentifyFloat(ImportsAllFloatsF1(0.0)) != 1 { - panic("unexpect result in ImportsIdentifyFloat") + if TestUnionsTestIdentifyFloat(TestUnionsTestAllFloatsF1(0.0)) != 1 { + panic("unexpect result in TestUnionsTestIdentifyFloat") } // All Text - if ImportsIdentifyText(ImportsAllTextF0('a')) != 0 { - panic("unexpected result in ImportsIdentifyText") + if TestUnionsTestIdentifyText(TestUnionsTestAllTextF0('a')) != 0 { + panic("unexpected result in TestUnionsTestIdentifyText") } - if ImportsIdentifyText(ImportsAllTextF1("abc")) != 1 { - panic("unexpected result in ImportsIdentifyText") + if TestUnionsTestIdentifyText(TestUnionsTestAllTextF1("abc")) != 1 { + panic("unexpected result in TestUnionsTestIdentifyText") } // All Duplicated - res21 := ImportsAddOneDuplicated(ImportsDuplicatedS32F0(0)) + res21 := TestUnionsTestAddOneDuplicated(TestUnionsTestDuplicatedS32F0(0)) if res21.GetF0() != 1 { - panic("unexpected result in ImportsAddOneDuplicated") + panic("unexpected result in TestUnionsTestAddOneDuplicated") } - res22 := ImportsAddOneDuplicated(ImportsDuplicatedS32F1(1)) + res22 := TestUnionsTestAddOneDuplicated(TestUnionsTestDuplicatedS32F1(1)) if res22.GetF1() != 2 { - panic("unexpected result in ImportsAddOneDuplicated") + panic("unexpected result in TestUnionsTestAddOneDuplicated") } - res23 := ImportsAddOneDuplicated(ImportsDuplicatedS32F2(2)) + res23 := TestUnionsTestAddOneDuplicated(TestUnionsTestDuplicatedS32F2(2)) if res23.GetF2() != 3 { - panic("unexpected result in ImportsAddOneDuplicated") + panic("unexpected result in TestUnionsTestAddOneDuplicated") } // Distinguishable - if ImportsAddOneDistinguishableNum(ImportsDistinguishableNumF1(0)).GetF1() != 1 { - panic("unexpect result in ImportsAddOneDistinguishableNum") + if TestUnionsTestAddOneDistinguishableNum(TestUnionsTestDistinguishableNumF1(0)).GetF1() != 1 { + panic("unexpect result in TestUnionsTestAddOneDistinguishableNum") } - if ImportsIdentifyDistinguishableNum(ImportsDistinguishableNumF0(0.0)) != 0 { - panic("unexpect result in ImportsIdentifyDistinguishableNum") + if TestUnionsTestIdentifyDistinguishableNum(TestUnionsTestDistinguishableNumF0(0.0)) != 0 { + panic("unexpect result in TestUnionsTestIdentifyDistinguishableNum") } - if ImportsIdentifyDistinguishableNum(ImportsDistinguishableNumF1(1)) != 1 { - panic("unexpect result in ImportsIdentifyDistinguishableNum") + if TestUnionsTestIdentifyDistinguishableNum(TestUnionsTestDistinguishableNumF1(1)) != 1 { + panic("unexpect result in TestUnionsTestIdentifyDistinguishableNum") } } -func (u UnionsImpl) AddOneInteger(num ExportsAllIntegers) ExportsAllIntegers { +func (u UnionsImpl) AddOneInteger(num ExportsTestUnionsTestAllIntegers) ExportsTestUnionsTestAllIntegers { switch num.Kind() { - case ExportsAllIntegersKindF0: - return ExportsAllIntegersF0(!num.GetF0()) - case ExportsAllIntegersKindF1: - return ExportsAllIntegersF1(num.GetF1() + 1) - case ExportsAllIntegersKindF2: - return ExportsAllIntegersF2(num.GetF2() + 1) - case ExportsAllIntegersKindF3: - return ExportsAllIntegersF3(num.GetF3() + 1) - case ExportsAllIntegersKindF4: - return ExportsAllIntegersF4(num.GetF4() + 1) - case ExportsAllIntegersKindF5: - return ExportsAllIntegersF5(num.GetF5() + 1) - case ExportsAllIntegersKindF6: - return ExportsAllIntegersF6(num.GetF6() + 1) - case ExportsAllIntegersKindF7: - return ExportsAllIntegersF7(num.GetF7() + 1) - case ExportsAllIntegersKindF8: - return ExportsAllIntegersF8(num.GetF8() + 1) + case ExportsTestUnionsTestAllIntegersKindF0: + return ExportsTestUnionsTestAllIntegersF0(!num.GetF0()) + case ExportsTestUnionsTestAllIntegersKindF1: + return ExportsTestUnionsTestAllIntegersF1(num.GetF1() + 1) + case ExportsTestUnionsTestAllIntegersKindF2: + return ExportsTestUnionsTestAllIntegersF2(num.GetF2() + 1) + case ExportsTestUnionsTestAllIntegersKindF3: + return ExportsTestUnionsTestAllIntegersF3(num.GetF3() + 1) + case ExportsTestUnionsTestAllIntegersKindF4: + return ExportsTestUnionsTestAllIntegersF4(num.GetF4() + 1) + case ExportsTestUnionsTestAllIntegersKindF5: + return ExportsTestUnionsTestAllIntegersF5(num.GetF5() + 1) + case ExportsTestUnionsTestAllIntegersKindF6: + return ExportsTestUnionsTestAllIntegersF6(num.GetF6() + 1) + case ExportsTestUnionsTestAllIntegersKindF7: + return ExportsTestUnionsTestAllIntegersF7(num.GetF7() + 1) + case ExportsTestUnionsTestAllIntegersKindF8: + return ExportsTestUnionsTestAllIntegersF8(num.GetF8() + 1) default: - panic("unexpected type in ExportsAllIntegers") + panic("unexpected type in ExportsTestUnionsTestAllIntegers") } } -func (u UnionsImpl) AddOneFloat(num ExportsAllFloats) ExportsAllFloats { +func (u UnionsImpl) AddOneFloat(num ExportsTestUnionsTestAllFloats) ExportsTestUnionsTestAllFloats { switch num.Kind() { - case ExportsAllFloatsKindF0: - return ExportsAllFloatsF0(num.GetF0() + 1.0) - case ExportsAllFloatsKindF1: - return ExportsAllFloatsF1(num.GetF1() + 1.0) + case ExportsTestUnionsTestAllFloatsKindF0: + return ExportsTestUnionsTestAllFloatsF0(num.GetF0() + 1.0) + case ExportsTestUnionsTestAllFloatsKindF1: + return ExportsTestUnionsTestAllFloatsF1(num.GetF1() + 1.0) default: - panic("unexpected type in ExportsAllFloats") + panic("unexpected type in ExportsTestUnionsTestAllFloats") } } -func (u UnionsImpl) ReplaceFirstChar(text ExportsAllText, letter rune) ExportsAllText { +func (u UnionsImpl) ReplaceFirstChar(text ExportsTestUnionsTestAllText, letter rune) ExportsTestUnionsTestAllText { switch text.Kind() { - case ExportsAllTextKindF0: - return ExportsAllTextF0(letter) - case ExportsAllTextKindF1: - return ExportsAllTextF1(string(letter) + text.GetF1()[1:]) + case ExportsTestUnionsTestAllTextKindF0: + return ExportsTestUnionsTestAllTextF0(letter) + case ExportsTestUnionsTestAllTextKindF1: + return ExportsTestUnionsTestAllTextF1(string(letter) + text.GetF1()[1:]) default: // handle error or panic - return ExportsAllText{} + return ExportsTestUnionsTestAllText{} } } -func (u UnionsImpl) IdentifyInteger(num ExportsAllIntegers) uint8 { +func (u UnionsImpl) IdentifyInteger(num ExportsTestUnionsTestAllIntegers) uint8 { switch num.Kind() { - case ExportsAllIntegersKindF0: + case ExportsTestUnionsTestAllIntegersKindF0: return 0 - case ExportsAllIntegersKindF1: + case ExportsTestUnionsTestAllIntegersKindF1: return 1 - case ExportsAllIntegersKindF2: + case ExportsTestUnionsTestAllIntegersKindF2: return 2 - case ExportsAllIntegersKindF3: + case ExportsTestUnionsTestAllIntegersKindF3: return 3 - case ExportsAllIntegersKindF4: + case ExportsTestUnionsTestAllIntegersKindF4: return 4 - case ExportsAllIntegersKindF5: + case ExportsTestUnionsTestAllIntegersKindF5: return 5 - case ExportsAllIntegersKindF6: + case ExportsTestUnionsTestAllIntegersKindF6: return 6 - case ExportsAllIntegersKindF7: + case ExportsTestUnionsTestAllIntegersKindF7: return 7 - case ExportsAllIntegersKindF8: + case ExportsTestUnionsTestAllIntegersKindF8: return 8 default: - panic("unexpected type in ExportsAllIntegers") + panic("unexpected type in ExportsTestUnionsTestAllIntegers") } } -func (u UnionsImpl) IdentifyFloat(num ExportsAllFloats) uint8 { +func (u UnionsImpl) IdentifyFloat(num ExportsTestUnionsTestAllFloats) uint8 { switch num.Kind() { - case ExportsAllFloatsKindF0: + case ExportsTestUnionsTestAllFloatsKindF0: return 0 - case ExportsAllFloatsKindF1: + case ExportsTestUnionsTestAllFloatsKindF1: return 1 default: - panic("unexpected type in ExportsAllFloats") + panic("unexpected type in ExportsTestUnionsTestAllFloats") } } -func (u UnionsImpl) IdentifyText(text ExportsAllText) uint8 { +func (u UnionsImpl) IdentifyText(text ExportsTestUnionsTestAllText) uint8 { switch text.Kind() { - case ExportsAllTextKindF0: + case ExportsTestUnionsTestAllTextKindF0: return 0 - case ExportsAllTextKindF1: + case ExportsTestUnionsTestAllTextKindF1: return 1 default: - panic("unexpected type in ExportsAllText") + panic("unexpected type in ExportsTestUnionsTestAllText") } } -func (u UnionsImpl) AddOneDuplicated(num ExportsDuplicatedS32) ExportsDuplicatedS32 { +func (u UnionsImpl) AddOneDuplicated(num ExportsTestUnionsTestDuplicatedS32) ExportsTestUnionsTestDuplicatedS32 { switch num.Kind() { - case ExportsDuplicatedS32KindF0: - return ExportsDuplicatedS32F0(num.GetF0() + 1) - case ExportsDuplicatedS32KindF1: - return ExportsDuplicatedS32F1(num.GetF1() + 1) - case ExportsDuplicatedS32KindF2: - return ExportsDuplicatedS32F2(num.GetF2() + 1) + case ExportsTestUnionsTestDuplicatedS32KindF0: + return ExportsTestUnionsTestDuplicatedS32F0(num.GetF0() + 1) + case ExportsTestUnionsTestDuplicatedS32KindF1: + return ExportsTestUnionsTestDuplicatedS32F1(num.GetF1() + 1) + case ExportsTestUnionsTestDuplicatedS32KindF2: + return ExportsTestUnionsTestDuplicatedS32F2(num.GetF2() + 1) default: - panic("unexpected type in ExportsDuplicatedS32") + panic("unexpected type in ExportsTestUnionsTestDuplicatedS32") } } -func (u UnionsImpl) IdentifyDuplicated(num ExportsDuplicatedS32) uint8 { +func (u UnionsImpl) IdentifyDuplicated(num ExportsTestUnionsTestDuplicatedS32) uint8 { switch num.Kind() { - case ExportsDuplicatedS32KindF0: + case ExportsTestUnionsTestDuplicatedS32KindF0: return 0 - case ExportsDuplicatedS32KindF1: + case ExportsTestUnionsTestDuplicatedS32KindF1: return 1 - case ExportsDuplicatedS32KindF2: + case ExportsTestUnionsTestDuplicatedS32KindF2: return 2 default: panic("unexpected type in IdentifyDuplicated") } } -func (u UnionsImpl) AddOneDistinguishableNum(num ExportsDistinguishableNum) ExportsDistinguishableNum { +func (u UnionsImpl) AddOneDistinguishableNum(num ExportsTestUnionsTestDistinguishableNum) ExportsTestUnionsTestDistinguishableNum { switch num.Kind() { - case ExportsDistinguishableNumKindF0: - return ExportsDistinguishableNumF0(num.GetF0() + 1.0) - case ExportsDistinguishableNumKindF1: - return ExportsDistinguishableNumF1(num.GetF1() + 1) + case ExportsTestUnionsTestDistinguishableNumKindF0: + return ExportsTestUnionsTestDistinguishableNumF0(num.GetF0() + 1.0) + case ExportsTestUnionsTestDistinguishableNumKindF1: + return ExportsTestUnionsTestDistinguishableNumF1(num.GetF1() + 1) default: - panic("unexpected type in ExportsDistinguishableNum") + panic("unexpected type in ExportsTestUnionsTestDistinguishableNum") } } -func (u UnionsImpl) IdentifyDistinguishableNum(num ExportsDistinguishableNum) uint8 { +func (u UnionsImpl) IdentifyDistinguishableNum(num ExportsTestUnionsTestDistinguishableNum) uint8 { switch num.Kind() { - case ExportsDistinguishableNumKindF0: + case ExportsTestUnionsTestDistinguishableNumKindF0: return 0 - case ExportsDistinguishableNumKindF1: + case ExportsTestUnionsTestDistinguishableNumKindF1: return 1 default: - panic("unexpected type in ExportsDistinguishableNum") + panic("unexpected type in ExportsTestUnionsTestDistinguishableNum") } }