Lines
100 %
Functions
Branches
//! `COMPILE` / `EVAL` / `DESCRIBE` special forms.
use super::common::{compile_and_validate, compile_expect_error};
#[test]
fn eval_with_quoted_constant() {
compile_and_validate("(eval '(+ 1 2))");
}
fn eval_with_quoted_arithmetic() {
compile_and_validate("(eval '(* 3 4))");
fn eval_wrong_arity_errors() {
let err = compile_expect_error("(eval)");
assert!(err.contains("eval"), "got: {err}");
fn compile_quoted_user_function() {
compile_and_validate("(defun greet () \"hello\") (compile 'greet)");
fn compile_unknown_symbol_errors() {
let err = compile_expect_error("(compile 'no-such-function)");
assert!(
err.contains("Undefined") || err.contains("no-such-function"),
"got: {err}",
);
fn compile_wrong_arity_errors() {
let err = compile_expect_error("(compile)");
assert!(err.contains("compile"), "got: {err}");
fn compile_non_quoted_symbol_errors() {
let err = compile_expect_error("(compile 42)");
assert!(err.contains("quoted symbol"), "got: {err}");
fn describe_native_returns_string() {
compile_and_validate("(describe '+)");
fn describe_unknown_symbol_errors() {
let err = compile_expect_error("(describe 'no-such-name)");
err.contains("Undefined") || err.contains("no-such-name"),
fn describe_wrong_arity_errors() {
let err = compile_expect_error("(describe)");
assert!(err.contains("DESCRIBE"), "got: {err}");
fn describe_user_function() {
compile_and_validate("(defun example (x) (+ x 1)) (describe 'example)");
fn describe_variable() {
compile_and_validate("(defvar my-num 42) (describe 'my-num)");