test_gen: support RocResult for Wasm tests

This commit is contained in:
Brian Carroll 2022-07-06 08:59:50 +01:00
parent 617e18af98
commit a9aee13086
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7
4 changed files with 49 additions and 6 deletions

View file

@ -1,4 +1,4 @@
use roc_std::{RocDec, RocList, RocOrder, RocStr};
use roc_std::{RocDec, RocList, RocOrder, RocStr, RocResult};
pub trait Wasm32Sized: Sized {
const SIZE_OF_WASM: usize;
@ -41,6 +41,11 @@ impl<T: Wasm32Sized> Wasm32Sized for RocList<T> {
const ALIGN_OF_WASM: usize = 4;
}
impl<T: Wasm32Sized, E: Wasm32Sized> Wasm32Sized for RocResult<T, E> {
const ALIGN_OF_WASM: usize = max2(T::ALIGN_OF_WASM, E::ALIGN_OF_WASM);
const SIZE_OF_WASM: usize = max2(T::ACTUAL_WIDTH, E::ACTUAL_WIDTH) + 1;
}
impl<T: Wasm32Sized> Wasm32Sized for &'_ T {
const SIZE_OF_WASM: usize = 4;
const ALIGN_OF_WASM: usize = 4;