1
//! Comparison forms beyond `=`/`<`/`>`/`<=`/`>=` — `/=`, EQL,
2
//! EQUAL, NOT, NULL?. Each covers both constant-fold and runtime
3
//! dispatch paths.
4

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

            
7
#[test]
8
1
fn neq_constant_fold_equal() {
9
1
    compile_and_validate("(/= 1 1)");
10
1
}
11

            
12
#[test]
13
1
fn neq_constant_fold_unequal() {
14
1
    compile_and_validate("(/= 1 2)");
15
1
}
16

            
17
#[test]
18
1
fn neq_runtime() {
19
1
    compile_and_validate(&wrap_with_runtime_ratio("(/= X 0)"));
20
1
}
21

            
22
#[test]
23
1
fn eql_constant_fold_equal() {
24
1
    compile_and_validate("(eql 1 1)");
25
1
}
26

            
27
#[test]
28
1
fn eql_constant_fold_unequal_types() {
29
1
    compile_and_validate("(eql 1 \"one\")");
30
1
}
31

            
32
#[test]
33
1
fn eql_runtime() {
34
1
    compile_and_validate(&wrap_with_runtime_ratio("(eql X 0)"));
35
1
}
36

            
37
#[test]
38
1
fn equal_constant_fold() {
39
1
    compile_and_validate("(equal '(1 2) '(1 2))");
40
1
}
41

            
42
#[test]
43
1
fn equal_runtime_with_strings() {
44
1
    compile_and_validate("(equal \"foo\" \"foo\")");
45
1
}
46

            
47
#[test]
48
1
fn not_true_is_false() {
49
1
    compile_and_validate("(not #t)");
50
1
}
51

            
52
#[test]
53
1
fn not_false_is_true() {
54
1
    compile_and_validate("(not #f)");
55
1
}
56

            
57
#[test]
58
1
fn not_nil_is_true() {
59
1
    compile_and_validate("(not nil)");
60
1
}
61

            
62
#[test]
63
1
fn not_runtime() {
64
1
    compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0))"));
65
1
}
66

            
67
#[test]
68
1
fn null_p_nil_is_true() {
69
1
    compile_and_validate("(null? nil)");
70
1
}
71

            
72
#[test]
73
1
fn null_p_non_nil_is_false() {
74
1
    compile_and_validate("(null? 1)");
75
1
}
76

            
77
#[test]
78
1
fn null_p_runtime_list() {
79
    // `(cons 1 nil)` produces a runtime pair-ref. null? checks it.
80
1
    compile_and_validate("(null? (cons 1 nil))");
81
1
}
82

            
83
#[test]
84
1
fn comparison_with_runtime_lhs_constant_rhs_uses_reversed_dispatch() {
85
    // Constant on the left + runtime on the right exercises the
86
    // `compile_cmp_to_stack_reversed` helper.
87
1
    compile_and_validate(&wrap_with_runtime_ratio("(< 0 X)"));
88
1
}