1
//! Reach the eval-handler bodies for entity accessors. Top-level
2
//! `(entity-type IDX)` dispatches to `compile_*_to_stack` directly,
3
//! bypassing the eval handler. Embedding the call inside an
4
//! expression that constant-folds via `eval_value` (comparison,
5
//! arithmetic, or symbol coercion) forces the eval path to run.
6

            
7
use super::common::{compile_and_validate, wrap_with_runtime_i32};
8

            
9
#[test]
10
1
fn entity_type_via_equality_eval() {
11
1
    compile_and_validate(&wrap_with_runtime_i32(
12
1
        "(= (entity-type IDX) +entity-transaction+)",
13
1
    ));
14
1
}
15

            
16
#[test]
17
1
fn entity_parent_idx_via_equality_eval() {
18
1
    compile_and_validate(&wrap_with_runtime_i32("(= (entity-parent-idx IDX) IDX)"));
19
1
}
20

            
21
#[test]
22
1
fn transaction_split_count_via_equality_eval() {
23
1
    compile_and_validate(&wrap_with_runtime_i32(
24
1
        "(= (transaction-split-count IDX) 0)",
25
1
    ));
26
1
}
27

            
28
#[test]
29
1
fn transaction_tag_count_via_equality_eval() {
30
1
    compile_and_validate(&wrap_with_runtime_i32("(= (transaction-tag-count IDX) 0)"));
31
1
}
32

            
33
#[test]
34
1
fn transaction_is_multi_currency_via_if() {
35
1
    compile_and_validate(&wrap_with_runtime_i32(
36
1
        "(if (transaction-is-multi-currency IDX) 1 0)",
37
1
    ));
38
1
}
39

            
40
#[test]
41
1
fn split_reconcile_state_via_equality_eval() {
42
1
    compile_and_validate(&wrap_with_runtime_i32("(= (split-reconcile-state IDX) 0)"));
43
1
}
44

            
45
#[test]
46
1
fn entity_type_inside_dolist() {
47
1
    compile_and_validate(
48
1
        "(let* ((acc 0)) \
49
1
           (dolist (i (get-input-entities)) \
50
1
             (if (= (entity-type i) +entity-transaction+) \
51
1
                 (setf acc (+ acc 1)))) \
52
1
           acc)",
53
    );
54
1
}
55

            
56
#[test]
57
1
fn nested_entity_accessor_chains() {
58
1
    compile_and_validate(&wrap_with_runtime_i32(
59
1
        "(if (= (entity-type IDX) +entity-split+) \
60
1
             (= (split-reconcile-state IDX) 0) \
61
1
             #f)",
62
1
    ));
63
1
}