1
//! `PP` and `APROPOS` builtins (DESCRIBE tests live in
2
//! `compile_eval_form.rs`). PP returns the formatted-text form of
3
//! its arg; APROPOS returns a quoted list of registry names matching
4
//! a substring.
5

            
6
use super::common::{compile_and_validate, compile_expect_error};
7

            
8
#[test]
9
1
fn pp_of_constant_number() {
10
1
    compile_and_validate("(pp 42)");
11
1
}
12

            
13
#[test]
14
1
fn pp_of_string() {
15
1
    compile_and_validate("(pp \"hello\")");
16
1
}
17

            
18
#[test]
19
1
fn pp_of_list() {
20
1
    compile_and_validate("(pp '(1 2 3))");
21
1
}
22

            
23
#[test]
24
1
fn pp_of_bool() {
25
1
    compile_and_validate("(pp #t)");
26
1
}
27

            
28
#[test]
29
1
fn pp_of_nil() {
30
1
    compile_and_validate("(pp nil)");
31
1
}
32

            
33
#[test]
34
1
fn pp_wrong_arity_errors() {
35
1
    let err = compile_expect_error("(pp)");
36
1
    assert!(err.contains("PP"), "got: {err}");
37
1
}
38

            
39
#[test]
40
1
fn pp_too_many_args_errors() {
41
1
    let err = compile_expect_error("(pp 1 2)");
42
1
    assert!(err.contains("PP"), "got: {err}");
43
1
}
44

            
45
#[test]
46
1
fn apropos_with_string_substring() {
47
1
    compile_and_validate("(apropos \"entity\")");
48
1
}
49

            
50
#[test]
51
1
fn apropos_with_symbol_substring() {
52
1
    compile_and_validate("(apropos transaction)");
53
1
}
54

            
55
#[test]
56
1
fn apropos_with_quoted_string() {
57
1
    compile_and_validate("(apropos 'list)");
58
1
}
59

            
60
#[test]
61
1
fn apropos_empty_match_is_empty_list() {
62
1
    compile_and_validate("(apropos \"no-such-thing-anywhere\")");
63
1
}
64

            
65
#[test]
66
1
fn apropos_wrong_arity_errors() {
67
1
    let err = compile_expect_error("(apropos)");
68
1
    assert!(err.contains("APROPOS"), "got: {err}");
69
1
}
70

            
71
#[test]
72
1
fn apropos_non_string_errors() {
73
1
    let err = compile_expect_error("(apropos 42)");
74
1
    assert!(err.contains("APROPOS"), "got: {err}");
75
1
}