Lines
100 %
Functions
Branches
//! Comparison forms beyond `=`/`<`/`>`/`<=`/`>=` — `/=`, EQL,
//! EQUAL, NOT, NULL?. Each covers both constant-fold and runtime
//! dispatch paths.
use super::common::{compile_and_validate, wrap_with_runtime_ratio};
#[test]
fn neq_constant_fold_equal() {
compile_and_validate("(/= 1 1)");
}
fn neq_constant_fold_unequal() {
compile_and_validate("(/= 1 2)");
fn neq_runtime() {
compile_and_validate(&wrap_with_runtime_ratio("(/= X 0)"));
fn eql_constant_fold_equal() {
compile_and_validate("(eql 1 1)");
fn eql_constant_fold_unequal_types() {
compile_and_validate("(eql 1 \"one\")");
fn eql_runtime() {
compile_and_validate(&wrap_with_runtime_ratio("(eql X 0)"));
fn equal_constant_fold() {
compile_and_validate("(equal '(1 2) '(1 2))");
fn equal_runtime_with_strings() {
compile_and_validate("(equal \"foo\" \"foo\")");
fn not_true_is_false() {
compile_and_validate("(not #t)");
fn not_false_is_true() {
compile_and_validate("(not #f)");
fn not_nil_is_true() {
compile_and_validate("(not nil)");
fn not_runtime() {
compile_and_validate(&wrap_with_runtime_ratio("(not (= X 0))"));
fn null_p_nil_is_true() {
compile_and_validate("(null? nil)");
fn null_p_non_nil_is_false() {
compile_and_validate("(null? 1)");
fn null_p_runtime_list() {
// `(cons 1 nil)` produces a runtime pair-ref. null? checks it.
compile_and_validate("(null? (cons 1 nil))");
fn comparison_with_runtime_lhs_constant_rhs_uses_reversed_dispatch() {
// Constant on the left + runtime on the right exercises the
// `compile_cmp_to_stack_reversed` helper.
compile_and_validate(&wrap_with_runtime_ratio("(< 0 X)"));