test(interface-types) Test Type::Record.

This commit is contained in:
Ivan Enderlin
2020-03-26 11:18:24 +01:00
parent c3c6fcbfdd
commit bddb4e90ee
5 changed files with 74 additions and 31 deletions

View File

@ -451,13 +451,14 @@ mod tests {
}
#[test]
fn test_type() {
fn test_type_function() {
assert_to_bytes!(
Type {
Type::Function {
inputs: vec![InterfaceType::I32, InterfaceType::I64],
outputs: vec![InterfaceType::S32],
},
&[
0x00, // function type
0x02, // list of 2 items
0x0c, // I32
0x0d, // I64
@ -467,6 +468,21 @@ mod tests {
);
}
#[test]
fn test_type_record() {
assert_to_bytes!(
Type::Record {
fields: vec![InterfaceType::I32, InterfaceType::I64],
},
&[
0x01, // record type
0x02, // list of 2 items
0x0c, // I32
0x0d, // I64
]
);
}
#[test]
fn test_import() {
assert_to_bytes!(
@ -504,7 +520,7 @@ mod tests {
fn test_interfaces() {
assert_to_bytes!(
Interfaces {
types: vec![Type {
types: vec![Type::Function {
inputs: vec![InterfaceType::S8],
outputs: vec![InterfaceType::S16],
}],
@ -529,6 +545,7 @@ mod tests {
&[
0x00, // type section
0x01, // 1 type
0x00, // function type
0x01, // list of 1 item
0x00, // S8
0x01, // list of 1 item