1
//! Acceptance rows tagged phase 3 in `doc/ops/0010-common-lisp-booleans.org`:
2
//! `t` identity through a `$pair` car, arm reconciliation beside a count, and
3
//! the compile errors a nil seed/argument raises against a `Never` type.
4

            
5
use super::*;
6

            
7
#[tokio::test]
8
1
async fn list_of_t_and_nil_renders_both_spellings() {
9
1
    assert_values(&[("(list t nil)", "(t nil)")]).await;
10
1
}
11

            
12
#[tokio::test]
13
1
async fn eq_recognises_t_and_nil_by_identity_through_a_pair_car() {
14
1
    assert_values(&[
15
1
        ("(eq? t (car (list t)))", "t"),
16
1
        ("(eq? nil (car (list nil)))", "t"),
17
1
        ("(null? (car (list nil t)))", "t"),
18
1
    ])
19
1
    .await;
20
1
}
21

            
22
#[tokio::test]
23
1
async fn a_missing_else_beside_a_count_is_nil_and_the_count_when_true() {
24
1
    assert_values(&[
25
1
        (
26
1
            "(if (> (rpc-protocol-version) 5) (rpc-protocol-version))",
27
1
            "nil",
28
1
        ),
29
1
        (
30
1
            "(if (> (rpc-protocol-version) 0) (rpc-protocol-version))",
31
1
            "1",
32
1
        ),
33
1
    ])
34
1
    .await;
35
1
}
36

            
37
#[tokio::test]
38
1
async fn unless_with_a_false_test_runs_its_body() {
39
1
    assert_values(&[("(unless (> (rpc-protocol-version) 5) 1)", "1")]).await;
40
1
}
41

            
42
#[tokio::test]
43
1
async fn nil_into_a_never_type_is_a_compile_error() {
44
1
    let response = eval_value_of("(let ((f (lambda (n) (+ n 1)))) (funcall f nil))").await;
45
1
    assert!(
46
1
        response.contains(":code compile") && response.contains("nil is not a scalar"),
47
1
        "got: {response}"
48
1
    );
49
1
}