Lines
100 %
Functions
Branches
use super::*;
use crate::reader::Reader;
fn body_calls_self(body: &str) -> bool {
let ctx = CompileContext::new_with_host_fns(&[]).expect("context");
let body = Reader::parse_expr(body).expect("parse");
body_calls_inlining_or_self(&ctx, "F", &body)
}
#[test]
fn a_self_call_under_a_template_quote_is_found() {
assert!(body_calls_self("`(a ',(f 1))"));
fn a_self_call_in_template_data_is_not_found() {
assert!(!body_calls_self("`(a (f 1))"));
fn an_any_parameter_takes_the_typed_list_its_argument_compiles_to() {
let mut ctx = CompileContext::new_with_host_fns(&[]).expect("context");
let mut emit = FunctionEmitter::new();
let mut symbols = SymbolTable::with_builtins_for_wasm();
let arg = Reader::parse_expr("(list (lambda () 8))").expect("parse");
emit_runtime_call(
&mut ctx,
&mut emit,
&mut symbols,
&[arg],
&[WasmType::AnyRef],
&MonomorphEntry {
func_idx: 0,
ret_ty: WasmType::AnyRef,
slots: Vec::new(),
},
)
.expect("an any parameter takes any value");
fn a_typed_parameter_still_refuses_another_type() {
let err = emit_runtime_call(
&[WasmType::Ratio],
ret_ty: WasmType::Ratio,
.expect_err("mismatch");
assert!(err.to_string().contains("argument type mismatch"), "{err}");