1
//! Tests for `emit_box_cell` (moved out of `boxing.rs` per CLAUDE.md's
2
//! file-size guideline).
3

            
4
use super::*;
5
use crate::compiler::context::CompileContext;
6

            
7
/// ADR-0033: a `Bool` car boxes identically whether its cell is typed
8
/// `PairElement::Bool` or the widened `PairElement::AnyRef` — both go
9
/// through `box_bool` (`ref.null` / the `$t` singleton), never an i31.
10
/// Pins the "no rebuild needed on widening" invariant at the byte level.
11
#[test]
12
1
fn pair_bool_and_pair_anyref_cells_box_a_bool_identically() {
13
1
    let ctx = CompileContext::new_with_host_fns(&[]).expect("ctx");
14
1
    let mut in_bool_cell = FunctionEmitter::new();
15
1
    emit_box_cell(
16
1
        &ctx,
17
1
        &mut in_bool_cell,
18
1
        PairElement::Bool,
19
1
        PairElement::Bool,
20
1
    );
21
1
    let mut in_anyref_cell = FunctionEmitter::new();
22
1
    emit_box_cell(
23
1
        &ctx,
24
1
        &mut in_anyref_cell,
25
1
        PairElement::Bool,
26
1
        PairElement::AnyRef,
27
1
    );
28
1
    assert_eq!(in_bool_cell.bytes_ref(), in_anyref_cell.bytes_ref());
29
1
}