1
//! Coverage gaps in `compiler/expr.rs` — keyword expressions, lambda
2
//! literals at value position, quasiquote with various inner shapes,
3
//! quoted lists in different positions.
4

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

            
7
#[test]
8
1
fn keyword_at_value_position() {
9
1
    compile_and_validate(":my-keyword");
10
1
}
11

            
12
#[test]
13
1
fn lambda_literal_at_value_position() {
14
    // Lambda at value position serializes its textual form (via
15
    // `compile_string` of `format_expr(expr)`).
16
1
    compile_and_validate("(lambda (x) x)");
17
1
}
18

            
19
#[test]
20
1
fn nested_quasiquote_with_unquote() {
21
1
    compile_and_validate("(defvar x 5) `(a ,x b)");
22
1
}
23

            
24
#[test]
25
1
fn nested_quasiquote_with_unquote_splicing() {
26
1
    compile_and_validate("(defvar xs '(1 2 3)) `(start ,@xs end)");
27
1
}
28

            
29
#[test]
30
1
fn quasiquote_nested_list() {
31
1
    compile_and_validate("`(outer (inner ,(+ 1 1)))");
32
1
}
33

            
34
#[test]
35
1
fn quoted_constant_string() {
36
1
    compile_and_validate("'\"literal\"");
37
1
}
38

            
39
#[test]
40
1
fn quoted_bool() {
41
1
    compile_and_validate("'#t");
42
1
}
43

            
44
#[test]
45
1
fn quoted_nil() {
46
1
    compile_and_validate("'nil");
47
1
}
48

            
49
#[test]
50
1
fn quoted_number_fraction() {
51
1
    compile_and_validate("'(/ 1 4)");
52
1
}
53

            
54
#[test]
55
1
fn quoted_empty_list() {
56
1
    compile_and_validate("'()");
57
1
}
58

            
59
#[test]
60
1
fn unquote_outside_quasiquote_errors() {
61
1
    let err = compile_expect_error(",foo");
62
1
    assert!(
63
1
        err.contains("unquote") || err.contains("quasiquote"),
64
        "got: {err}"
65
    );
66
1
}
67

            
68
#[test]
69
1
fn empty_function_call_compiles_to_nil() {
70
    // Empty parens parse to an empty list which the compiler treats
71
    // as `nil` (the canonical empty-list representation).
72
1
    compile_and_validate("()");
73
1
}
74

            
75
#[test]
76
1
fn unbound_symbol_errors() {
77
1
    let err = compile_expect_error("xyzzy-undefined");
78
1
    assert!(
79
1
        err.contains("Undefined") || err.contains("xyzzy"),
80
        "got: {err}",
81
    );
82
1
}