Lines
96.67 %
Functions
80 %
Branches
100 %
//! The home type of a DO variable: its init joined with the hint the previous
//! attempt's refused stores left.
use crate::ast::{PairElement, WasmType};
use crate::compiler::join::Arm;
use crate::error::Error;
use super::super::binding::var_home_type;
#[test]
fn a_nil_init_var_joins_the_type_its_step_gives() {
let step = || Ok(Some(WasmType::I32));
assert_eq!(
var_home_type(Arm::Nil, None, step).expect("home"),
WasmType::AnyRef
);
var_home_type(Arm::Nil, None, || Ok(Some(WasmType::PairRef(
PairElement::I32
))))
.expect("home"),
WasmType::PairRef(PairElement::I32)
}
fn a_hint_widens_the_home_of_a_literal_init() {
let unsized_step = || Err(Error::Compile("not asked".to_string()));
let literal = Arm::NumberLiteral(WasmType::I32);
var_home_type(literal, Some(WasmType::Ratio), unsized_step).expect("home"),
WasmType::Ratio
var_home_type(literal, None, unsized_step).expect("home"),
WasmType::I32
var_home_type(
Arm::Value(WasmType::I32),
Some(WasmType::Ratio),
unsized_step
)