Lines
100 %
Functions
Branches
//! Reach the eval-handler bodies for entity accessors. Top-level
//! `(entity-type IDX)` dispatches to `compile_*_to_stack` directly,
//! bypassing the eval handler. Embedding the call inside an
//! expression that constant-folds via `eval_value` (comparison,
//! arithmetic, or symbol coercion) forces the eval path to run.
use super::common::{compile_and_validate, wrap_with_runtime_i32};
#[test]
fn entity_type_via_equality_eval() {
compile_and_validate(&wrap_with_runtime_i32(
"(= (entity-type IDX) +entity-transaction+)",
));
}
fn entity_parent_idx_via_equality_eval() {
compile_and_validate(&wrap_with_runtime_i32("(= (entity-parent-idx IDX) IDX)"));
fn transaction_split_count_via_equality_eval() {
"(= (transaction-split-count IDX) 0)",
fn transaction_tag_count_via_equality_eval() {
compile_and_validate(&wrap_with_runtime_i32("(= (transaction-tag-count IDX) 0)"));
fn transaction_is_multi_currency_via_if() {
"(if (transaction-is-multi-currency IDX) 1 0)",
fn split_reconcile_state_via_equality_eval() {
compile_and_validate(&wrap_with_runtime_i32("(= (split-reconcile-state IDX) 0)"));
fn entity_type_inside_dolist() {
compile_and_validate(
"(let* ((acc 0)) \
(dolist (i (get-input-entities)) \
(if (= (entity-type i) +entity-transaction+) \
(setf acc (+ acc 1)))) \
acc)",
);
fn nested_entity_accessor_chains() {
"(if (= (entity-type IDX) +entity-split+) \
(= (split-reconcile-state IDX) 0) \
#f)",