From 1fe97ea31ef1151052e2b7db97d56b42f444c890 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 18 Feb 2021 15:06:16 -0800 Subject: [PATCH] rename some wiggle tests to reflect new witx ast names arrays are now lists structs are now records unions are now variants this ruins some of my union puns, oh well --- crates/wiggle/tests/{arrays.rs => lists.rs} | 8 +++---- .../wiggle/tests/{arrays.witx => lists.witx} | 2 +- .../wiggle/tests/{structs.rs => records.rs} | 24 +++++++++---------- .../tests/{structs.witx => records.witx} | 6 ++--- crates/wiggle/tests/{union.rs => variant.rs} | 8 +++---- .../wiggle/tests/{union.witx => variant.witx} | 5 +--- 6 files changed, 25 insertions(+), 28 deletions(-) rename crates/wiggle/tests/{arrays.rs => lists.rs} (98%) rename crates/wiggle/tests/{arrays.witx => lists.witx} (98%) rename crates/wiggle/tests/{structs.rs => records.rs} (96%) rename crates/wiggle/tests/{structs.witx => records.witx} (93%) rename crates/wiggle/tests/{union.rs => variant.rs} (97%) rename crates/wiggle/tests/{union.witx => variant.witx} (82%) diff --git a/crates/wiggle/tests/arrays.rs b/crates/wiggle/tests/lists.rs similarity index 98% rename from crates/wiggle/tests/arrays.rs rename to crates/wiggle/tests/lists.rs index f5e577ba29..dd6f92c5d3 100644 --- a/crates/wiggle/tests/arrays.rs +++ b/crates/wiggle/tests/lists.rs @@ -3,13 +3,13 @@ use wiggle::{GuestMemory, GuestPtr, GuestType}; use wiggle_test::{impl_errno, HostMemory, MemArea, MemAreas, WasiCtx}; wiggle::from_witx!({ - witx: ["$CARGO_MANIFEST_DIR/tests/arrays.witx"], + witx: ["$CARGO_MANIFEST_DIR/tests/lists.witx"], ctx: WasiCtx, }); impl_errno!(types::Errno, types::GuestErrorConversion); -impl<'a> arrays::Arrays for WasiCtx<'a> { +impl<'a> lists::Lists for WasiCtx<'a> { fn reduce_excuses( &self, excuses: &types::ConstExcuseArray, @@ -97,7 +97,7 @@ impl ReduceExcusesExcercise { } } - let res = arrays::reduce_excuses( + let res = lists::reduce_excuses( &ctx, &host_memory, self.array_ptr_loc.ptr as i32, @@ -177,7 +177,7 @@ impl PopulateExcusesExcercise { .expect("failed to write value"); } - let res = arrays::populate_excuses( + let res = lists::populate_excuses( &ctx, &host_memory, self.array_ptr_loc.ptr as i32, diff --git a/crates/wiggle/tests/arrays.witx b/crates/wiggle/tests/lists.witx similarity index 98% rename from crates/wiggle/tests/arrays.witx rename to crates/wiggle/tests/lists.witx index 3522fc4096..aa7a3d997c 100644 --- a/crates/wiggle/tests/arrays.witx +++ b/crates/wiggle/tests/lists.witx @@ -4,7 +4,7 @@ (typename $const_excuse_array (list (@witx const_pointer $excuse))) (typename $excuse_array (list (@witx pointer $excuse))) -(module $arrays +(module $lists (@interface func (export "reduce_excuses") (param $excuses $const_excuse_array) (result $error (expected $excuse (error $errno))) diff --git a/crates/wiggle/tests/structs.rs b/crates/wiggle/tests/records.rs similarity index 96% rename from crates/wiggle/tests/structs.rs rename to crates/wiggle/tests/records.rs index 537ac0afb5..be44a44afc 100644 --- a/crates/wiggle/tests/structs.rs +++ b/crates/wiggle/tests/records.rs @@ -3,13 +3,13 @@ use wiggle::{GuestMemory, GuestPtr}; use wiggle_test::{impl_errno, HostMemory, MemArea, MemAreas, WasiCtx}; wiggle::from_witx!({ - witx: ["$CARGO_MANIFEST_DIR/tests/structs.witx"], + witx: ["$CARGO_MANIFEST_DIR/tests/records.witx"], ctx: WasiCtx, }); impl_errno!(types::Errno, types::GuestErrorConversion); -impl<'a> structs::Structs for WasiCtx<'a> { +impl<'a> records::Records for WasiCtx<'a> { fn sum_of_pair(&self, an_pair: &types::PairInts) -> Result { Ok(an_pair.first as i64 + an_pair.second as i64) } @@ -53,17 +53,17 @@ impl<'a> structs::Structs for WasiCtx<'a> { }) } - fn sum_array<'b>(&self, struct_of_arr: &types::StructOfArray<'b>) -> Result { + fn sum_array<'b>(&self, record_of_list: &types::RecordOfList<'b>) -> Result { // my kingdom for try blocks - fn aux(struct_of_arr: &types::StructOfArray) -> Result { + fn aux(record_of_list: &types::RecordOfList) -> Result { let mut s = 0; - for elem in struct_of_arr.arr.iter() { + for elem in record_of_list.arr.iter() { let v = elem?.read()?; s += v as u16; } Ok(s) } - match aux(struct_of_arr) { + match aux(record_of_list) { Ok(s) => Ok(s), Err(guest_err) => { eprintln!("guest error summing array: {:?}", guest_err); @@ -111,7 +111,7 @@ impl SumOfPairExercise { .ptr(self.input_loc.ptr + 4) .write(self.input.second) .expect("input ref_mut"); - let sum_err = structs::sum_of_pair( + let sum_err = records::sum_of_pair( &ctx, &host_memory, self.input_loc.ptr as i32, @@ -209,7 +209,7 @@ impl SumPairPtrsExercise { .write(self.input_second_loc.ptr) .expect("input_struct ref"); - let res = structs::sum_of_pair_of_ptrs( + let res = records::sum_of_pair_of_ptrs( &ctx, &host_memory, self.input_struct_loc.ptr as i32, @@ -292,7 +292,7 @@ impl SumIntAndPtrExercise { .write(self.input_second) .expect("input_struct ref"); - let res = structs::sum_of_int_and_ptr( + let res = records::sum_of_int_and_ptr( &ctx, &host_memory, self.input_struct_loc.ptr as i32, @@ -336,7 +336,7 @@ impl ReturnPairInts { let ctx = WasiCtx::new(); let host_memory = HostMemory::new(); - let err = structs::return_pair_ints(&ctx, &host_memory, self.return_loc.ptr as i32); + let err = records::return_pair_ints(&ctx, &host_memory, self.return_loc.ptr as i32); assert_eq!(err, Ok(types::Errno::Ok as i32), "return struct errno"); @@ -410,7 +410,7 @@ impl ReturnPairPtrsExercise { .write(self.input_second) .expect("input_second ref"); - let res = structs::return_pair_of_ptrs( + let res = records::return_pair_of_ptrs( &ctx, &host_memory, self.input_first_loc.ptr as i32, @@ -522,7 +522,7 @@ impl SumArrayExercise { .expect("write len to struct memory"); // Call wiggle-generated func - let res = structs::sum_array( + let res = records::sum_array( &ctx, &host_memory, self.input_struct_loc.ptr as i32, diff --git a/crates/wiggle/tests/structs.witx b/crates/wiggle/tests/records.witx similarity index 93% rename from crates/wiggle/tests/structs.witx rename to crates/wiggle/tests/records.witx index 16f5ced8ec..d09e37a38a 100644 --- a/crates/wiggle/tests/structs.witx +++ b/crates/wiggle/tests/records.witx @@ -18,14 +18,14 @@ (typename $some_bytes (list u8)) -(typename $struct_of_array +(typename $record_of_list (record (field $arr $some_bytes))) (typename $s64 s64) (typename $u16 u16) -(module $structs +(module $records (@interface func (export "sum_of_pair") (param $an_pair $pair_ints) (result $error (expected $s64 (error $errno)))) @@ -42,6 +42,6 @@ (param $second (@witx const_pointer s32)) (result $error (expected $pair_int_ptrs (error $errno)))) (@interface func (export "sum_array") - (param $an_arr $struct_of_array) + (param $a_list $record_of_list) (result $error (expected $u16 (error $errno)))) ) diff --git a/crates/wiggle/tests/union.rs b/crates/wiggle/tests/variant.rs similarity index 97% rename from crates/wiggle/tests/union.rs rename to crates/wiggle/tests/variant.rs index 04a1f4cce0..364fbbf7cf 100644 --- a/crates/wiggle/tests/union.rs +++ b/crates/wiggle/tests/variant.rs @@ -3,7 +3,7 @@ use wiggle::{GuestMemory, GuestType}; use wiggle_test::{impl_errno, HostMemory, MemArea, WasiCtx}; wiggle::from_witx!({ - witx: ["$CARGO_MANIFEST_DIR/tests/union.witx"], + witx: ["$CARGO_MANIFEST_DIR/tests/variant.witx"], ctx: WasiCtx, }); @@ -31,7 +31,7 @@ fn mult_zero_nan(a: f32, b: u32) -> f32 { } } -impl<'a> union_example::UnionExample for WasiCtx<'a> { +impl<'a> variant_example::VariantExample for WasiCtx<'a> { fn get_tag(&self, u: &types::Reason) -> Result { println!("GET TAG: {:?}", u); match u { @@ -126,7 +126,7 @@ impl GetTagExercise { .expect("input contents ref_mut"), types::Reason::Sleeping => {} // Do nothing } - let e = union_example::get_tag( + let e = variant_example::get_tag( &ctx, &host_memory, self.input_loc.ptr as i32, @@ -210,7 +210,7 @@ impl ReasonMultExercise { } types::Reason::Sleeping => {} // Do nothing } - let e = union_example::reason_mult( + let e = variant_example::reason_mult( &ctx, &host_memory, self.input_loc.ptr as i32, diff --git a/crates/wiggle/tests/union.witx b/crates/wiggle/tests/variant.witx similarity index 82% rename from crates/wiggle/tests/union.witx rename to crates/wiggle/tests/variant.witx index 0559666b8a..87640d4bec 100644 --- a/crates/wiggle/tests/union.witx +++ b/crates/wiggle/tests/variant.witx @@ -1,9 +1,6 @@ (use "errno.witx") (use "excuse.witx") -;; Every worker needs a union. Organize your workplace! -;; Fight for the full product of your labor! - (typename $reason (variant (@witx tag $excuse) (case $dog_ate f32) @@ -16,7 +13,7 @@ (case $traffic (@witx pointer s32)) (case $sleeping))) -(module $union_example +(module $variant_example (@interface func (export "get_tag") (param $r $reason) (result $error (expected $excuse (error $errno)))