Lines
100 %
Functions
Branches
//! Coverage gaps in `compiler/expr.rs` — keyword expressions, lambda
//! literals at value position, quasiquote with various inner shapes,
//! quoted lists in different positions.
use super::common::{compile_and_validate, compile_expect_error};
#[test]
fn keyword_at_value_position() {
compile_and_validate(":my-keyword");
}
fn lambda_literal_at_value_position() {
// Lambda at value position serializes its textual form (via
// `compile_string` of `format_expr(expr)`).
compile_and_validate("(lambda (x) x)");
fn nested_quasiquote_with_unquote() {
compile_and_validate("(defvar x 5) `(1 ,x 2)");
fn nested_quasiquote_with_unquote_splicing() {
compile_and_validate("(defvar xs '(1 2 3)) `(0 ,@xs 4)");
fn quasiquote_nested_list() {
compile_and_validate("(defvar x 5) `(1 (2 ,x))");
/// A quasiquote whose template holds a symbol expands to a list datum with
/// symbol members, a `$pair` chain of `$symbol` cells (plan 0014 Stage 8).
fn quasiquote_with_a_symbol_member_is_a_list() {
for src in [
"(defvar x 5) `(a ,x b)",
"(defvar xs '(1 2 3)) `(start ,@xs end)",
"`(outer (inner 1))",
] {
compile_and_validate(src);
fn quoted_constant_string() {
compile_and_validate("'\"literal\"");
fn quoted_bool() {
compile_and_validate("'t");
fn quoted_nil() {
compile_and_validate("'nil");
fn quoted_number_fraction() {
compile_and_validate("'1/4");
/// `'(/ 1 4)` is a list datum whose head is the symbol `/`, not a fraction.
fn quoted_division_form_is_a_symbol_list() {
compile_and_validate("'(/ 1 4)");
fn quoted_empty_list() {
compile_and_validate("'()");
fn unquote_outside_quasiquote_errors() {
let err = compile_expect_error(",foo");
assert!(
err.contains("unquote") || err.contains("quasiquote"),
"got: {err}"
);
fn empty_function_call_compiles_to_nil() {
// Empty parens parse to an empty list which the compiler treats
// as `nil` (the canonical empty-list representation).
compile_and_validate("()");
fn unbound_symbol_errors() {
let err = compile_expect_error("xyzzy-undefined");
err.contains("Undefined") || err.contains("xyzzy"),
"got: {err}",