Lines
100 %
Functions
Branches
//! CONS / `$pair` construction codegen. The Commodity-specific
//! type-mismatch tests moved into the inline `list::tests` module
//! since they exercise the private `infer_pair_element` directly —
//! script-mode lacks a Commodity producer, and the unit tests are
//! the right level for that contract.
use super::common::compile_and_validate;
#[test]
fn nil_car_beside_runtime_string_cell_widens_to_anyref() {
// A `nil` car takes the Bool slot, so beside a string cell the chain widens
// to AnyRef and nil rides as a null ref — never a typed null in a string
// cell that `CAR`'s non-null cast would trap on.
compile_and_validate("(let* ((idx (entity-count))) (cons nil (cons (tag-name idx) nil)))");
}
fn integer_cons_chain() {
// P3a 3a.2: all-integer literal cons chain rides $pair with
// `PairElement::I32`. Replaces the pre-migration i32-only `$cons`.
compile_and_validate("(cons 1 (cons 2 (cons 3 nil)))");
fn pair_of_ratios() {
// P3a 3a.3: per-element pair codegen handles Ratio cars without
// the legacy `capture_pending_ratio` helper.
compile_and_validate("(cons (/ 1 2) (cons (/ 3 4) nil))");
fn pair_of_strings() {
compile_and_validate("(cons \"hi\" (cons \"world\" nil))");