Merge pull request #2668 from bytecodealliance/pch/rename_some_wiggle_tests
rename some wiggle tests to reflect new witx ast names
This commit is contained in:
@@ -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,
|
||||
@@ -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)))
|
||||
@@ -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<i64, types::Errno> {
|
||||
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<u16, types::Errno> {
|
||||
fn sum_array<'b>(&self, record_of_list: &types::RecordOfList<'b>) -> Result<u16, types::Errno> {
|
||||
// my kingdom for try blocks
|
||||
fn aux(struct_of_arr: &types::StructOfArray) -> Result<u16, wiggle::GuestError> {
|
||||
fn aux(record_of_list: &types::RecordOfList) -> Result<u16, wiggle::GuestError> {
|
||||
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,
|
||||
@@ -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))))
|
||||
)
|
||||
@@ -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<types::Excuse, types::Errno> {
|
||||
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,
|
||||
@@ -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)))
|
||||
Reference in New Issue
Block a user