1
//! The acceptance rows of plans 0011 and 0014 run here, through the
2
//! `Session`: `nms -e` is a convenience, not evidence (0014 §Acceptance-suite
3
//! repair) — it cannot compile catch-each (an rpc-only import), has no
4
//! `(rpc-protocol-version)` and no DB natives. A row whose expectation is a
5
//! catch-each result or a DB value lives in this module.
6

            
7
use super::*;
8
use nomiscript::{Number, Reader};
9

            
10
mod account_check_log_tests;
11
mod block_mirror_and_dispatch_tests;
12
mod cl_boolean_tests;
13
mod codex_round10_regression_tests;
14
mod codex_round11_regression_tests;
15
mod codex_round1_regression_tests;
16
mod codex_round2_regression_tests;
17
mod codex_round3_regression_tests;
18
mod codex_round4_regression_tests;
19
mod codex_round5_regression_tests;
20
mod codex_round6_regression_tests;
21
mod codex_round7_regression_tests;
22
mod codex_round8_regression_tests;
23
mod codex_round9_regression_tests;
24
mod completion_interrupt_tests;
25
mod engine_error_wire_tests;
26
mod error_detail_tests;
27
mod eval_metrics_tests;
28
mod eval_path_rendering_tests;
29
mod gj_global_home_tests;
30
mod identity_effect_tests;
31
mod instance_wire_tests;
32
mod list_tests;
33
mod native_fallback_tests;
34
mod native_stack_tests;
35
mod nil_boxing_tests;
36
mod opaque_wire_tests;
37
mod persist_bound_tests;
38
mod persist_closure_tests;
39
mod persist_tests;
40
mod phase0_splice_regression_tests;
41
mod phase3_boolean_tests;
42
mod phase4_control_tests;
43
mod phase6_anyref_decode_tests;
44
mod plan0011_phase3_acceptance_tests;
45
mod print_output_tests;
46
mod rebind_trap_tests;
47
mod request_envelope_tests;
48
mod session_natives_tests;
49
mod siteless_closure_wire_tests;
50
mod stage2_apply_funcall_tests;
51
mod stage2_captured_store_tests;
52
mod stage2_designator_tests;
53
mod stage2_eager_call_tests;
54
mod stage2_family_a_tests;
55
mod stage2_fold_error_consumers_tests;
56
mod stage2_handler_case_value_tests;
57
mod stage2_head_resolver_tests;
58
mod stage2_host_builtin_tests;
59
mod stage2_lambda_default_store_tests;
60
mod stage2_lambda_list_effects_tests;
61
mod stage2_let_init_effects_tests;
62
mod stage2_native_effects_tests;
63
mod stage2_operation_errors_tests;
64
mod stage2_probe_store_tests;
65
mod stage2_raising_mod_tests;
66
mod stage2_raising_operand_tests;
67
mod stage2_static_errors_tests;
68
mod stage2_synth_native_tests;
69
mod stage2_synth_progn_tests;
70
mod stage3_alias_chase_tests;
71
mod stage3_handler_value_tests;
72
mod stage3_lambda_value_tests;
73
mod stage3_macro_effect_tests;
74
mod stage3_macro_key_tests;
75
mod stage3_macro_list_data_tests;
76
mod stage3_quote_atoms_tests;
77
mod stage3_quote_constants_tests;
78
mod stage3_quote_form_tests;
79
mod stage3_transfer_tests;
80
mod stage56_expansion_value_tests;
81
mod stream_head_tests;
82
mod wire_depth_tests;
83
mod wire_list_tests;
84

            
85
447
async fn handle_form_smoke(frame: &str) -> String {
86
447
    let ctx = ScriptCtx::new(uuid::Uuid::nil());
87
447
    let mut session = Session::new(ctx).expect("Session::new");
88
447
    session.handle_form(frame).await
89
447
}
90

            
91
377
async fn eval_value_of(form: &str) -> String {
92
377
    handle_form_smoke(&format!("(:id 4 :form {form})")).await
93
377
}
94

            
95
197
async fn assert_values(cases: &[(&str, &str)]) {
96
197
    for (form, value) in cases {
97
294
        assert_eq!(
98
294
            eval_value_of(form).await,
99
294
            format!("(:id 4 :value {value})"),
100
            "form {form}"
101
        );
102
    }
103
197
}
104

            
105
/// A program the compiler can see is ill-typed is rejected whole: nothing runs
106
/// (user decision ISS-087).
107
88
async fn assert_unit_rejected(source: &str, message: &str) {
108
88
    let mut session = Session::new(ScriptCtx::new(uuid::Uuid::nil())).expect("Session::new");
109
88
    let outcome = session.handle_request(&format!("(progn {source})")).await;
110
88
    assert_eq!(outcome.output, "", "{source}: nothing may run");
111
88
    let ResponsePayload::Error { message: got, .. } = outcome.payload else {
112
        panic!("{source}: expected a compile error");
113
    };
114
88
    assert_eq!(got, message, "{source}");
115
88
}
116

            
117
1
async fn assert_builtin_rejected(source: &str, name: &str) {
118
1
    let message = format!("Compile error: '{name}' is a built-in and cannot be redefined");
119
1
    assert_unit_rejected(source, &message).await;
120
1
}
121

            
122
34
async fn assert_error_code(form: &str, code: &str) {
123
34
    let response = eval_value_of(form).await;
124
34
    assert!(
125
34
        response.contains(&format!(":code {code}")),
126
        "{form} must raise {code}, got: {response}"
127
    );
128
34
}
129

            
130
/// The expected value `value` stands for, as the wire reader would build it:
131
/// a quoted list is data, not the printed string `eval_program` yields for it.
132
337
fn parse_to_value(input: &str) -> Result<Value, NomiError> {
133
337
    let program = Reader::parse(input)?;
134
337
    let expr = match program.exprs.into_iter().next() {
135
48
        Some(nomiscript::Expr::Quote(inner)) => *inner,
136
289
        Some(expr) => expr,
137
        None => return Ok(Value::Nil),
138
    };
139
337
    Ok(crate::response::expr_to_value(expr))
140
337
}
141

            
142
102
fn value(text: &str) -> ResponsePayload {
143
102
    ResponsePayload::Value(parse_to_value(text).expect("expected value parses"))
144
102
}